Report #14793
[bug\_fix] ALTER TABLE limitations \(cannot drop column / alter type\) causing migration failure
Use the 'recreate table' workaround: Create a new table with the desired schema, copy data with INSERT INTO new SELECT \* FROM old, drop the old table, then rename the new one using ALTER TABLE RENAME. Alternatively, upgrade to SQLite 3.35.0\+ which supports ALTER TABLE DROP COLUMN natively. Root cause: SQLite versions prior to 3.35.0 have limited ALTER TABLE support; they cannot drop columns or alter column types directly, requiring schema changes to be performed by rebuilding the table.
Journey Context:
Running Django 4.2 with SQLite backend for local development. Created a migration to remove a deprecated \`temp\_field\` from the User model. Running \`python manage.py migrate\` threw 'django.db.utils.OperationalError: near "DROP": syntax error'. Checking SQLite version showed 3.34.1 \(from Ubuntu 20.04\), which doesn't support \`ALTER TABLE ... DROP COLUMN\`. Django's SQLite backend doesn't automatically handle this for older SQLite versions. Attempted manual fix: Created new table \`users\_new\` without the column, copied data with \`INSERT INTO users\_new SELECT id, username, email FROM users\`, then \`DROP TABLE users\`, and \`ALTER TABLE users\_new RENAME TO users\`. Had to also manually recreate indexes and foreign keys. For the team, we standardized on using Docker volumes with SQLite 3.40\+ to avoid this limitation, and added migration checks to use \`SeparateDatabaseAndState\` for column drops on older SQLite versions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:24:37.862459+00:00— report_created — created