﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21783	Adding a non-nullable field fails on SQLite	Florian Apolloner	Andrew Godwin <andrew@…>	"as the title says; just add a new field to a model and provide a default for existing rows; will fail during migration with:
{{{
Operations to perform:
  Synchronize unmigrated apps: admin, contenttypes, auth, sessions
  Apply all migrations: oversight
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Installed 0 object(s) from 0 fixture(s)
Running migrations:
  Applying oversight.0003_sensor_unit...Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/home/florian/sources/django.git/django/core/management/__init__.py"", line 427, in execute_from_command_line
    utility.execute()
  File ""/home/florian/sources/django.git/django/core/management/__init__.py"", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/home/florian/sources/django.git/django/core/management/base.py"", line 244, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/home/florian/sources/django.git/django/core/management/base.py"", line 291, in execute
    output = self.handle(*args, **options)
  File ""/home/florian/sources/django.git/django/core/management/commands/migrate.py"", line 145, in handle
    executor.migrate(targets, plan, fake=options.get(""fake"", False))
  File ""/home/florian/sources/django.git/django/db/migrations/executor.py"", line 60, in migrate
    self.apply_migration(migration, fake=fake)
  File ""/home/florian/sources/django.git/django/db/migrations/executor.py"", line 94, in apply_migration
    migration.apply(project_state, schema_editor)
  File ""/home/florian/sources/django.git/django/db/migrations/migration.py"", line 97, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File ""/home/florian/sources/django.git/django/db/migrations/operations/fields.py"", line 30, in database_forwards
    schema_editor.add_field(from_model, to_model._meta.get_field_by_name(self.name)[0])
  File ""/home/florian/sources/django.git/django/db/backends/sqlite3/schema.py"", line 91, in add_field
    self._remake_table(model, create_fields=[field])
  File ""/home/florian/sources/django.git/django/db/backends/sqlite3/schema.py"", line 63, in _remake_table
    self.quote_name(model._meta.db_table),
  File ""/home/florian/sources/django.git/django/db/backends/schema.py"", line 96, in execute
    cursor.execute(sql, params)
  File ""/home/florian/sources/django.git/django/db/backends/utils.py"", line 77, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File ""/home/florian/sources/django.git/django/db/backends/utils.py"", line 61, in execute
    return self.cursor.execute(sql, params)
  File ""/home/florian/sources/django.git/django/db/utils.py"", line 93, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File ""/home/florian/sources/django.git/django/db/backends/utils.py"", line 61, in execute
    return self.cursor.execute(sql, params)
  File ""/home/florian/sources/django.git/django/db/backends/sqlite3/base.py"", line 489, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: NOT NULL constraint failed: oversight_sensor__new.unit
}}}"	Bug	closed	Migrations	dev	Release blocker	fixed		Andrew Godwin info@…	Accepted	1	0	1	0	0	0
