Re: [Django] #34665: CreateModel with manually added RenameField crashes on SQLite. (was: An OperationalError is thrown when using SQLite database in Django 4.1 during 'migrate', while it works normally on versions below 4.1 and also works normally on MySQL.)

3 views
Skip to first unread message

Django

unread,
Jun 19, 2023, 3:07:24 AM6/19/23
to django-...@googlegroups.com
#34665: CreateModel with manually added RenameField crashes on SQLite.
-------------------------------------+-------------------------------------
Reporter: Amchii | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: sqlite3 | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

It worked on Django 4.0 because the `person` table was recreated by the
second migrations (which is no longer necessary in SQLite 3.35.5+, see
3702819227fd0cdd9b581cd99e11d1561d51cbeb), however in all versions of
Django index is created on a wrong column:
{{{
ALTER TABLE "person" RENAME COLUMN "open_id" TO "open_uid";
CREATE INDEX "person_open_id_aac92076" ON "person" ("open_id");
}}}

> Although I manually added a line instead of using makemigrations when
renaming the 'open_id' field, it should still work properly?

In general, you can edit migrations manually, but you do so at your own
risk. In this case you should update the column name in the `CreateModel`
operation instead of adding `RenameField`.

--
Ticket URL: <https://code.djangoproject.com/ticket/34665#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Reply all
Reply to author
Forward
0 new messages