Skip to content

Instantly share code, notes, and snippets.

@jasonferrier
Created May 9, 2012 19:19
Show Gist options
  • Save jasonferrier/2648156 to your computer and use it in GitHub Desktop.
Save jasonferrier/2648156 to your computer and use it in GitHub Desktop.
after manually creating api_* columns
jlfMBP:tntsite postgres$ python manage.py migrate tnt
/Users/jasonferrier/Sites/transitandtrails/tntsite/tnt/migrations/0019_auto__add_field_userprofile_api_secret__add_field_userprofile_api_key.py:9: SyntaxWarning: import * only allowed at module level
def forwards(self, orm):
Running migrations for tnt:
- Migrating forwards to 0052_auto__del_field_campground_bathrooms__del_field_campground_county__del.
> tnt:0019_auto__add_field_userprofile_api_secret__add_field_userprofile_api_key
FATAL ERROR - The following SQL query failed: ALTER TABLE "tnt_userprofile" ADD COLUMN "api_secret" text NULL DEFAULT '49c5830c61fbd6dc288f045b172648ae5094d0455c5fdfe59b20c1d6a5e70f27';
The error was: column "api_secret" of relation "tnt_userprofile" already exists
! 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 "tnt_userprofile" DROP COLUMN "api_secret" CASCADE; []
= ALTER TABLE "tnt_userprofile" DROP COLUMN "api_key" 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: tnt:0019_auto__add_field_userprofile_api_secret__add_field_userprofile_api_key
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 459, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/management/commands/migrate.py", line 107, in handle
ignore_ghosts = ignore_ghosts,
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/__init__.py", line 219, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 235, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 310, in migrate_many
result = self.migrate(migration, database)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 133, in migrate
result = self.run(migration)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 107, in run
return self.run_migration(migration)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 81, in run_migration
migration_function()
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/migration/migrators.py", line 57, in <lambda>
return (lambda: direction(orm))
File "/Users/jasonferrier/Sites/transitandtrails/tntsite/tnt/migrations/0019_auto__add_field_userprofile_api_secret__add_field_userprofile_api_key.py", line 12, in forwards
db.add_column('tnt_userprofile', 'api_secret', self.gf('django.db.models.fields.TextField')(default='49c5830c61fbd6dc288f045b172648ae5094d0455c5fdfe59b20c1d6a5e70f27', null=True, blank=True), keep_default=False)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/db/generic.py", line 46, in _cache_clear
return func(self, table, *args, **opts)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/db/generic.py", line 408, in add_column
self.execute(sql)
File "/Library/Python/2.7/site-packages/South-0.7.4-py2.7.egg/south/db/generic.py", line 264, in execute
cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
return self.cursor.execute(query, args)
django.db.utils.DatabaseError: column "api_secret" of relation "tnt_userprofile" already exists
jlfMBP:tntsite postgres$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment