forked from mtusi2026/mtusi2026lab3
Adopt async SQLAlchemy storage and verified Alembic migrations
Keep the message and idempotency receipt in one Core CTE statement with chat-first locking. Preserve rollback, bounded dependency failures, and domain ports. Replace the SQL runner with Alembic. Adopt legacy databases only after validating their journal and PostgreSQL schema, retain all data, and verify migrations on fresh and populated databases.
This commit is contained in:
@@ -211,6 +211,16 @@ def sql_tables(zone: str, tables: tuple[str, ...]) -> set[str]:
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Constant) and isinstance(node.value, str):
|
||||
words.update(re.findall(r"\b(?:FROM|JOIN|INTO|UPDATE)\s+(\w+)", node.value))
|
||||
if (
|
||||
isinstance(node, ast.Assign)
|
||||
and any(
|
||||
isinstance(target, ast.Name) and target.id == "__tablename__"
|
||||
for target in node.targets
|
||||
)
|
||||
and isinstance(node.value, ast.Constant)
|
||||
and isinstance(node.value.value, str)
|
||||
):
|
||||
words.add(node.value.value)
|
||||
return words & set(tables)
|
||||
|
||||
|
||||
@@ -227,3 +237,11 @@ def test_messaging_does_not_import_identity_at_all() -> None:
|
||||
for path in modules_under("messaging")
|
||||
}
|
||||
assert not {key: value for key, value in borrowed.items() if value}
|
||||
|
||||
|
||||
def test_sqlalchemy_stays_in_infrastructure_and_asyncpg_is_only_a_driver() -> None:
|
||||
for path in SOURCE.rglob("*.py"):
|
||||
modules = {module.split(".")[0] for module in imports_of(path)}
|
||||
assert "asyncpg" not in modules
|
||||
if "infrastructure" not in path.parts:
|
||||
assert "sqlalchemy" not in modules
|
||||
|
||||
Reference in New Issue
Block a user