Skip to content

Instantly share code, notes, and snippets.

@sethwoodworth
Created July 24, 2012 16:58
Show Gist options
  • Save sethwoodworth/3171175 to your computer and use it in GitHub Desktop.
Save sethwoodworth/3171175 to your computer and use it in GitHub Desktop.
./manage.py migrate notes
Running migrations for notes:
- Migrating forwards to 0006_auto__add_field_userprofile_hash.
> notes:0004_auto__add_field_userprofile_hash
FATAL ERROR - The following SQL query failed: ALTER TABLE "notes_userprofile" ADD COLUMN "hash" varchar(255) NOT NULL;
The error was: column "hash" contains null values
! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
! You *might* be able to recover with: = ALTER TABLE "notes_userprofile" DROP COLUMN "hash" CASCADE; []
= DROP TABLE "notes_userprofile_courses" CASCADE; []
! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS (one that supports DDL transactions)
! NOTE: The error which caused the migration to fail is further up.
Error in migration: notes:0004_auto__add_field_userprofile_hash
Traceback (most recent call last):
File "./manage.py", line 24, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 107, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 219, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 235, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 310, in migrate_many
result = self.migrate(migration, database)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 133, in migrate
result = self.run(migration)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 107, in run
return self.run_migration(migration)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 57, in <lambda>
return (lambda: direction(orm))
File "/var/www/beta/notes/migrations/0004_auto__add_field_userprofile_hash.py", line 14, in forwards
keep_default=False)
File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 46, in _cache_clear
return func(self, table, *args, **opts)
File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 408, in add_column
self.execute(sql)
File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 264, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
return self.cursor.execute(query, args)
django.db.utils.IntegrityError: column "hash" contains null values
node@www:/var/www/beta$ vim notes/models.py
node@www:/var/www/beta$ rm notes/migrations/0006*
node@www:/var/www/beta$ ./manage.py schemamigration notes --auto
+ Added field hash on notes.UserProfile
Created 0006_auto__add_field_userprofile_hash.py. You can now apply this migration with: ./manage.py migrate notes
node@www:/var/www/beta$ ./manage.py migrate notes
Running migrations for notes:
- Migrating forwards to 0006_auto__add_field_userprofile_hash.
> notes:0004_auto__add_field_userprofile_hash
FATAL ERROR - The following SQL query failed: ALTER TABLE "notes_userprofile" ADD COLUMN "hash" varchar(255) NOT NULL;
The error was: column "hash" contains null values
! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.
! You *might* be able to recover with: = ALTER TABLE "notes_userprofile" DROP COLUMN "hash" CASCADE; []
= DROP TABLE "notes_userprofile_courses" CASCADE; []
! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS (one that supports DDL transactions)
! NOTE: The error which caused the migration to fail is further up.
Error in migration: notes:0004_auto__add_field_userprofile_hash
Traceback (most recent call last):
File "./manage.py", line 24, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/south/management/commands/migrate.py", line 107, in handle
ignore_ghosts = ignore_ghosts,
File "/usr/local/lib/python2.7/dist-packages/south/migration/__init__.py", line 219, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 235, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 310, in migrate_many
result = self.migrate(migration, database)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 133, in migrate
result = self.run(migration)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 107, in run
return self.run_migration(migration)
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/usr/local/lib/python2.7/dist-packages/south/migration/migrators.py", line 57, in <lambda>
return (lambda: direction(orm))
File "/var/www/beta/notes/migrations/0004_auto__add_field_userprofile_hash.py", line 14, in forwards
keep_default=False)
File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 46, in _cache_clear
return func(self, table, *args, **opts)
File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 408, in add_column
self.execute(sql)
File "/usr/local/lib/python2.7/dist-packages/south/db/generic.py", line 264, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
return self.cursor.execute(query, args)
django.db.utils.IntegrityError: column "hash" contains null values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment