This reverts 2529b51. Not a retreat — a reordering, on the operator's
call, and the better sequence.
The squash's acceptance test (run 4971) found ~130 places where the ORM
models do not describe the deployed schema (#3275), including a
unique=True the database never had and two UNIQUE indexes that exist
only in migrations. Collapsing now would have baked all of that into the
one file a public installer starts from.
So: fix the drift first as ordinary migrations on the intact chain, let
the operator deploy so their database moves to the corrected head, and
only then collapse. The baseline is then generated from reconciled
models and reproduces a schema worth reproducing.
Nothing is lost by reverting. The baseline was never deployed, and
regenerating it after the fixes is strictly better than patching this
copy — it will come out of autogenerate correct rather than needing the
same hand-finishing twice.
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
"""Smoke test for migration 0002: confirms model classes import and the
|
|
tag-kind uniqueness rule shape is correct.
|
|
"""
|
|
|
|
from backend.app.models import (
|
|
Base,
|
|
ImportBatch,
|
|
ImportSettings,
|
|
ImportTask,
|
|
Tag,
|
|
TagKind,
|
|
)
|
|
|
|
|
|
def test_new_tables_registered():
|
|
expected = {"import_batch", "import_task", "import_settings"}
|
|
assert expected.issubset(Base.metadata.tables.keys())
|
|
|
|
|
|
def test_tag_has_kind_and_fandom_id():
|
|
cols = {c.name for c in Tag.__table__.columns}
|
|
assert "kind" in cols
|
|
assert "fandom_id" in cols
|
|
assert "namespace" not in cols
|
|
|
|
|
|
def test_tag_kind_enum_values():
|
|
# Current TagKind enum after alembic 0023 dropped meta + rating
|
|
# (operator-retired 2026-05-26). `artist` is still in the enum
|
|
# for backward-compat with historical rows, though new artist
|
|
# tags don't get created (Artist row is canonical per FC-2d-vii-c).
|
|
expected = {
|
|
"artist",
|
|
"character",
|
|
"fandom",
|
|
"general",
|
|
"series",
|
|
"archive",
|
|
"post",
|
|
}
|
|
assert {k.value for k in TagKind} == expected
|
|
|
|
|
|
def test_image_record_has_integrity_status():
|
|
from backend.app.models import ImageRecord
|
|
cols = {c.name for c in ImageRecord.__table__.columns}
|
|
assert "integrity_status" in cols
|
|
|
|
|
|
def test_import_task_has_state_columns():
|
|
cols = {c.name for c in ImportTask.__table__.columns}
|
|
for required in ("batch_id", "source_path", "task_type", "status", "result_image_id"):
|
|
assert required in cols
|
|
|
|
|
|
def test_import_settings_singleton_constraint():
|
|
constraints = {c.name for c in ImportSettings.__table__.constraints}
|
|
assert "ck_import_settings_singleton" in constraints
|