diff --git a/app/migrations.py b/app/migrations.py index 61b1b23..6711536 100644 --- a/app/migrations.py +++ b/app/migrations.py @@ -2971,9 +2971,7 @@ async def _migrate_049_foreign_key_cascade(conn: aiosqlite.Connection) -> None: logger.info("Database backed up to %s before FK migration", backup_path) # --- Phase 1: clean orphans (guard each table's existence) --- - tables_cursor = await conn.execute( - "SELECT name FROM sqlite_master WHERE type='table'" - ) + tables_cursor = await conn.execute("SELECT name FROM sqlite_master WHERE type='table'") existing_tables = {row[0] for row in await tables_cursor.fetchall()} if "contact_advert_paths" in existing_tables and "contacts" in existing_tables: @@ -3021,9 +3019,7 @@ async def _migrate_049_foreign_key_cascade(conn: aiosqlite.Connection) -> None: if "payload_hash" in old_cols: new_col_defs.append("payload_hash BLOB") copy_cols.append("payload_hash") - new_col_defs.append( - "FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE SET NULL" - ) + new_col_defs.append("FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE SET NULL") cols_sql = ", ".join(new_col_defs) copy_sql = ", ".join(copy_cols) @@ -3103,5 +3099,3 @@ async def _migrate_049_foreign_key_cascade(conn: aiosqlite.Connection) -> None: ) await conn.commit() logger.debug("Rebuilt contact_name_history with ON DELETE CASCADE") - - diff --git a/scripts/quality/all_quality.sh b/scripts/quality/all_quality.sh index 6bf7380..ff96840 100755 --- a/scripts/quality/all_quality.sh +++ b/scripts/quality/all_quality.sh @@ -26,7 +26,7 @@ echo -e "${YELLOW}=== Phase 1: Lint & Format ===${NC}" echo -ne "${BLUE}[backend lint]${NC} " cd "$REPO_ROOT" uv run ruff check app/ tests/ --fix --quiet -uv run ruff format app/ tests/ --check --quiet +uv run ruff format app/ tests/ --quiet echo -e "${GREEN}Passed!${NC}" echo -ne "${BLUE}[frontend lint]${NC} " diff --git a/tests/test_api.py b/tests/test_api.py index 264655b..4b82358 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1199,12 +1199,18 @@ class TestRawPacketRepository: """Purge linked raw packets removes only rows with a message_id.""" ts = int(time.time()) msg_id_1 = await MessageRepository.create( - msg_type="PRIV", conversation_key="k1", text="t1", - sender_timestamp=ts, received_at=ts, + msg_type="PRIV", + conversation_key="k1", + text="t1", + sender_timestamp=ts, + received_at=ts, ) msg_id_2 = await MessageRepository.create( - msg_type="PRIV", conversation_key="k2", text="t2", - sender_timestamp=ts, received_at=ts, + msg_type="PRIV", + conversation_key="k2", + text="t2", + sender_timestamp=ts, + received_at=ts, ) linked_1, _ = await RawPacketRepository.create(b"\x01\x02\x03", ts) linked_2, _ = await RawPacketRepository.create(b"\x04\x05\x06", ts) @@ -1248,12 +1254,18 @@ class TestMaintenanceEndpoint: ts = int(time.time()) msg_id_1 = await MessageRepository.create( - msg_type="PRIV", conversation_key="k1", text="t1", - sender_timestamp=ts, received_at=ts, + msg_type="PRIV", + conversation_key="k1", + text="t1", + sender_timestamp=ts, + received_at=ts, ) msg_id_2 = await MessageRepository.create( - msg_type="PRIV", conversation_key="k2", text="t2", - sender_timestamp=ts, received_at=ts, + msg_type="PRIV", + conversation_key="k2", + text="t2", + sender_timestamp=ts, + received_at=ts, ) linked_1, _ = await RawPacketRepository.create(b"\x0a\x0b\x0c", ts) linked_2, _ = await RawPacketRepository.create(b"\x0d\x0e\x0f", ts)