Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#33960 closed Bug (fixed)

migrate command crashes on SQLite < 3.20.

Reported by: Aristotelis Mikropoulos Owned by: Mariusz Felisiak
Component: Core (Management commands) Version: 4.1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Creating a fresh project and app in a fresh virtual environment, then adding the app in INSTALLED_APPS (either bare name, or appname.apps.AppnameConfig), and then running python manage.py migrate causes:

$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying auth.0001_initial...Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/core/management/base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 349, in handle
    post_migrate_state = executor.migrate(
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/db/migrations/executor.py", line 255, in apply_migration
    migration_recorded = True
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/db/backends/sqlite3/schema.py", line 39, in __exit__
    self.connection.check_constraints()
  File "/home/indy/Desktop/env/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py", line 289, in check_constraints
    for column_name, (
ValueError: too many values to unpack (expected 2)

relations referenced in lines 289-292 of db/backends/sqlite3/base.py

for column_name, (
    referenced_column_name,
    referenced_table_name,
) in relations:

contains {'permission_id': ('id', 'auth_permission'), 'group_id': ('id', 'auth_group')}, so it makes sense to cause the ValueError.

Ubuntu 16.04
Python 3.8
Django 4.1
I don't change any settings (so, sqlite3), don't define any models, don't do any other changes.

Change History (5)

comment:1 by Mariusz Felisiak, 2 years ago

Owner: changed from nobody to Mariusz Felisiak
Severity: NormalRelease blocker
Status: newassigned
Summary: `python manage.py migrate` causes `ValueError: too many values to unpack (expected 2)`migrate command crashes on SQLite < 3.20.
Triage Stage: UnreviewedAccepted

Thanks for the report! Regression in 0b95a96ee10d3e12aef01d449467bcf4641286b4.

comment:2 by Mariusz Felisiak, 2 years ago

Has patch: set

comment:3 by GitHub <noreply@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 4483a9b:

Fixed #33960 -- Fixed migrations crash on SQLite < 3.26.

Regression in 0b95a96ee10d3e12aef01d449467bcf4641286b4.

Thanks Aristotelis Mikropoulos for the report.

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

In e98869a8:

[4.1.x] Fixed #33960 -- Fixed migrations crash on SQLite < 3.26.

Regression in 0b95a96ee10d3e12aef01d449467bcf4641286b4.

Thanks Aristotelis Mikropoulos for the report.
Backport of 4483a9b12f295908e68b82d6599f460de943444f from main

in reply to:  4 comment:5 by Aristotelis Mikropoulos, 2 years ago

Replying to Mariusz Felisiak <felisiak.mariusz@…>:

In e98869a8:

[4.1.x] Fixed #33960 -- Fixed migrations crash on SQLite < 3.26.

Regression in 0b95a96ee10d3e12aef01d449467bcf4641286b4.

Thanks Aristotelis Mikropoulos for the report.
Backport of 4483a9b12f295908e68b82d6599f460de943444f from main

You 're welcome.

Note: See TracTickets for help on using tickets.
Back to Top