fix(scheduling): repair missing participation gateway column

This commit is contained in:
2026-07-22 01:48:24 +02:00
parent 658dcca9d6
commit 95928e0585
2 changed files with 124 additions and 1 deletions

View File

@@ -20,7 +20,8 @@ from govoplan_scheduling.backend.db.models import (
from govoplan_scheduling.backend.manifest import get_manifest as get_scheduling_manifest
_SCHEDULING_HEAD = "ad7e3c9b2f10"
_SCHEDULING_HEAD = "be8f4d2c1a70"
_SCHEDULING_RESPONSE_SETTINGS_REVISION = "ad7e3c9b2f10"
_ENABLED_MODULES = ("poll", "scheduling")
_MANIFEST_FACTORIES = (get_poll_manifest, get_scheduling_manifest)
@@ -306,6 +307,63 @@ class SchedulingMigrationTests(unittest.TestCase):
finally:
engine.dispose()
def test_repairs_missing_participation_gateway_after_previous_head_was_stamped(self) -> None:
with tempfile.TemporaryDirectory(
prefix="govoplan-scheduling-migration-"
) as directory:
url = f"sqlite:///{Path(directory) / 'scheduling.db'}"
self._migrate(url)
engine = create_engine(url)
try:
self._seed_scheduling_rows(engine)
with engine.begin() as connection:
connection.execute(
text(
"DELETE FROM alembic_version WHERE version_num = :revision"
),
{"revision": _SCHEDULING_HEAD},
)
connection.execute(
text(
"INSERT INTO alembic_version (version_num) VALUES (:revision)"
),
{"revision": _SCHEDULING_RESPONSE_SETTINGS_REVISION},
)
connection.execute(
text(
"ALTER TABLE scheduling_participants "
"DROP COLUMN participation_gateway"
)
)
self._migrate(url)
with engine.connect() as connection:
heads = set(
MigrationContext.configure(connection).get_current_heads()
)
participant_columns = {
item["name"]
for item in inspect(connection).get_columns(
"scheduling_participants"
)
}
participant = connection.execute(
text(
"SELECT display_name, email, participation_gateway "
"FROM scheduling_participants WHERE id = 'participant-1'"
)
).one()
self.assertIn(_SCHEDULING_HEAD, heads)
self.assertIn("participation_gateway", participant_columns)
self.assertEqual(
tuple(participant),
("Ada", "ada@example.test", None),
)
finally:
engine.dispose()
if __name__ == "__main__":
unittest.main()