2020-12-08 django.db.utils.NotSupportedError: (sqlite)

I will migrate to new or empty database, but get interrupt with this error

(env) ↪ python3 gealtikdemo/manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, blog, contenttypes, portfolio, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying blog.0001_initial... OK
  Applying blog.0002_auto_20190906_1508... OK
  Applying blog.0003_auto_20190907_1004...Traceback (most recent call last):
  File "gealtikdemo/manage.py", line 21, in <module>
    main()
  File "gealtikdemo/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/bima/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/bima/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 395, in execute
...
django.db.utils.NotSupportedError: Renaming the 'blog_category' table while in a transaction is not supported on SQLite < 3.26 because it would break referential integrity. Try adding `atomic = False` to the Migration class.

But, we have the hint:

Try adding `atomic = False` to the Migration class.

I think this because the package settings (__init__.py) in site-packages are settings to False too. Because that I need to setting allllllllllllllllllllllllllllllllllllllllllllll migration file in my project.

Any solutions???????????????????? This is the way options (maybe) 🤪 :

  • downgrade SQLite or change this DB Don't do this!

  • set atomic value in site-packages (in python packages NOT in migration file) to true Not work!

  • reset or delete migrations Don't do this!

Check up how to setup Databases in https://docs.djangoproject.com/id/3.1/intro/tutorial02/

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

and I'm no problem with the statement the code are correct

Related case: Latest migrations break SQLite

What should I do??

Try adding `atomic = False` to the Migration class.

...in every migration file ??? 🧐

Okay, because I'm lazier I will do it tommorow 🤪

This exactly I needed

+1 I'm play bass toniiiiiight!!!

...

this is tommorow, and after add atomic = False to all migration file

(env) ↪ python3 gealtikdemo/manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, blog, contenttypes, portfolio, sessions
Running migrations:
  Applying blog.0003_auto_20190907_1004... OK
  Applying blog.0004_auto_20201208_1446... OK
  Applying portfolio.0001_initial... OK
  Applying portfolio.0002_auto_20190903_0318... OK
  Applying portfolio.0003_portfolio_portfolio_type... OK
  Applying portfolio.0004_auto_20190903_0619... OK
  Applying sessions.0001_initial... OK

Last updated

Was this helpful?