#35763: Setting the auto increment value of a database model breaks when you
add a
new field to the model
-------------------------------------+-------------------------------------
Reporter: Kevin Renskers | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Kevin Renskers):
The big problem is that I now need to add `migrations.RunSQL("UPDATE
sqlite_sequence SET seq = 50000 WHERE name = 'content_content'")` to
''every single migration'' that adds a new field to my model, or my tests
start to fail in CI (which runs using SQLite). Locally (using PostgreSQL)
all tests pass just fine.
Some background on why I need to change the auto increment value: website
content with IDs until 50,000 are stored in an old historical table, and
my view fetches the content from the correct model based on the ID: lower
than 50,000 use the old model, newer use the new model. My unit tests
break when I create a new `Content` instance, expect its ID to be at least
50,000, but instead the ID is 1 and the view handles it in a way that's
not expected.
--
Ticket URL: <https://code.djangoproject.com/ticket/35763#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070191f6cca874-1904881e-bb31-4330-9c1f-b4f7194bb6b0-000000%40eu-central-1.amazonses.com.