Opened 7 years ago
Closed 7 years ago
#28813 closed Bug (duplicate)
Sqlite migration of manual primary key
Description ¶
Sqlite migration generates an invalid INSERT INTO clause when a table has no more columns. (happens with manual primary keys)
BEGIN; -- -- Remove field f1 from poc -- ALTER TABLE "app_poc" RENAME TO "app_poc__old"; CREATE TABLE "app_poc" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT); INSERT INTO "app_poc" () SELECT FROM "app_poc__old"; DROP TABLE "app_poc__old"; -- -- Add field f2 to poc -- ALTER TABLE "app_poc" RENAME TO "app_poc__old"; CREATE TABLE "app_poc" ("f2" integer NOT NULL PRIMARY KEY); INSERT INTO "app_poc" ("f2") SELECT 1 FROM "app_poc__old"; DROP TABLE "app_poc__old"; COMMIT;
https://github.com/cecedille1/django-migrate-empty-columns-poc
Note:
See TracTickets
for help on using tickets.
One way to fix this is to create the new field first before removing the old one