File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,11 +10,23 @@ def migrate_api_tokens(apps, schema_editor):
1010 PREFIX_LENGTH = 8
1111
1212 with schema_editor .connection .cursor () as cursor :
13- cursor .execute (
14- "SELECT EXISTS (SELECT 1 FROM information_schema.tables "
15- "WHERE table_name = 'authtoken_token')"
16- )
17- table_exists = cursor .fetchone ()[0 ]
13+ # Check if authtoken_token table exists (works for both PostgreSQL and SQLite)
14+ db_vendor = schema_editor .connection .vendor
15+
16+ if db_vendor == 'postgresql' :
17+ cursor .execute (
18+ "SELECT EXISTS (SELECT 1 FROM information_schema.tables "
19+ "WHERE table_name = 'authtoken_token')"
20+ )
21+ table_exists = cursor .fetchone ()[0 ]
22+ elif db_vendor == 'sqlite' :
23+ cursor .execute (
24+ "SELECT name FROM sqlite_master WHERE type='table' AND name='authtoken_token'"
25+ )
26+ table_exists = cursor .fetchone () is not None
27+ else :
28+ # For other databases, assume table doesn't exist
29+ table_exists = False
1830
1931 if not table_exists :
2032 return
You can’t perform that action at this time.
0 commit comments