99or more steps, asserts the expected state, then restores to head before the
1010next test, ensuring the shared SQLite database remains consistent for any
1111subsequent test runs.
12+
13+ These tests are SQLite-only: they open the database file directly via
14+ sqlite3.connect() to inspect raw state, which is not possible with PostgreSQL.
1215"""
1316
1417import sqlite3
1518
19+ import pytest
1620from alembic import command
1721
1822from databases .player_database import DATABASE_URL
1923from tests .conftest import ALEMBIC_CONFIG
2024
25+ pytestmark = pytest .mark .skipif (
26+ not DATABASE_URL .startswith ("sqlite" ),
27+ reason = "Migration downgrade tests require SQLite" ,
28+ )
29+
2130DB_PATH = DATABASE_URL .replace ("sqlite+aiosqlite:///" , "" )
2231
2332
@@ -30,11 +39,11 @@ def test_migration_downgrade_003_removes_substitutes_only():
3039 subs = conn .execute ("SELECT COUNT(*) FROM players WHERE starting11=0" ).fetchone ()[0 ]
3140 conn .close ()
3241
33- command .upgrade (ALEMBIC_CONFIG , "head" )
34-
3542 assert total == 11
3643 assert subs == 0
3744
45+ command .upgrade (ALEMBIC_CONFIG , "head" )
46+
3847
3948def test_migration_downgrade_002_removes_starting11_only ():
4049 """Downgrade 002→001 removes the 11 seeded Starting XI, leaves table empty."""
@@ -44,10 +53,10 @@ def test_migration_downgrade_002_removes_starting11_only():
4453 total = conn .execute ("SELECT COUNT(*) FROM players" ).fetchone ()[0 ]
4554 conn .close ()
4655
47- command .upgrade (ALEMBIC_CONFIG , "head" )
48-
4956 assert total == 0
5057
58+ command .upgrade (ALEMBIC_CONFIG , "head" )
59+
5160
5261def test_migration_downgrade_001_drops_players_table ():
5362 """Downgrade 001→base drops the players table entirely."""
@@ -59,6 +68,6 @@ def test_migration_downgrade_001_drops_players_table():
5968 ).fetchone ()
6069 conn .close ()
6170
62- command .upgrade (ALEMBIC_CONFIG , "head" )
63-
6471 assert table is None
72+
73+ command .upgrade (ALEMBIC_CONFIG , "head" )
0 commit comments