feat: prepare postgres sbom cutover
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a028f0-a42f-7582-89a8-ebaad7343834
This commit is contained in:
parent
cf7e3acb78
commit
ba535e1f8f
26 changed files with 1573 additions and 411 deletions
38
tests/test_migrations.py
Normal file
38
tests/test_migrations.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from alembic import command
|
||||
from alembic.config import Config
|
||||
from sqlalchemy import create_engine, inspect
|
||||
|
||||
|
||||
def migration_config(database_path: Path) -> Config:
|
||||
config = Config("alembic.ini")
|
||||
config.set_main_option("sqlalchemy.url", f"sqlite:///{database_path}")
|
||||
return config
|
||||
|
||||
|
||||
def test_initial_migration_upgrades_and_downgrades(tmp_path: Path) -> None:
|
||||
database_path = tmp_path / "migrated.db"
|
||||
config = migration_config(database_path)
|
||||
|
||||
command.upgrade(config, "head")
|
||||
|
||||
engine = create_engine(f"sqlite:///{database_path}")
|
||||
assert set(inspect(engine).get_table_names()) == {
|
||||
"alembic_version",
|
||||
"entries",
|
||||
"repositories",
|
||||
"snapshots",
|
||||
}
|
||||
assert {index["name"] for index in inspect(engine).get_indexes("entries")} == {
|
||||
"ix_entries_license",
|
||||
"ix_entries_repo",
|
||||
"ix_entries_snapshot",
|
||||
}
|
||||
command.check(config)
|
||||
|
||||
command.downgrade(config, "base")
|
||||
|
||||
assert set(inspect(engine).get_table_names()) == {"alembic_version"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue