Skip to content

Instantly share code, notes, and snippets.

@vortec
Created January 5, 2015 11:11
Show Gist options
  • Select an option

  • Save vortec/743265050944602fc287 to your computer and use it in GitHub Desktop.

Select an option

Save vortec/743265050944602fc287 to your computer and use it in GitHub Desktop.
(sentry)[root@ci] ~sentry # ./bin/sentry --config=etc/conf.py migrate
Running migrations for djcelery:
- Nothing to migrate.
- Loading initial data for djcelery.
Installed 0 object(s) from 0 fixture(s)
Running migrations for django:
- Nothing to migrate.
- Loading initial data for django.
Installed 0 object(s) from 0 fixture(s)
Running migrations for sentry:
- Migrating forwards to 0150_fix_broken_rules.
> sentry:0135_auto__chg_field_project_team
FATAL ERROR - The following SQL query failed: ALTER TABLE "sentry_project" ALTER COLUMN "team_id" TYPE integer, ALTER COLUMN "team_id" SET NOT NULL, ALTER COLUMN "team_id" DROP DEFAULT;
The error was: column "team_id" contains null values
Error in migration: sentry:0135_auto__chg_field_project_team
Traceback (most recent call last):
File "./bin/sentry", line 9, in <module>
load_entry_point('sentry==7.0.2', 'console_scripts', 'sentry')()
File "/opt/sentry/local/lib/python2.7/site-packages/sentry/utils/runner.py", line 384, in main
initializer=initialize_app,
File "/opt/sentry/local/lib/python2.7/site-packages/logan/runner.py", line 169, in run_app
management.execute_from_command_line([runner_name, command] + command_args)
File "/opt/sentry/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/opt/sentry/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/sentry/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/opt/sentry/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/opt/sentry/local/lib/python2.7/site-packages/south/management/commands/migrate.py", line 111, in handle
ignore_ghosts = ignore_ghosts,
File "/opt/sentry/local/lib/python2.7/site-packages/south/migration/__init__.py", line 220, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/opt/sentry/local/lib/python2.7/site-packages/south/migration/migrators.py", line 256, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/opt/sentry/local/lib/python2.7/site-packages/south/migration/migrators.py", line 331, in migrate_many
result = self.migrate(migration, database)
File "/opt/sentry/local/lib/python2.7/site-packages/south/migration/migrators.py", line 133, in migrate
result = self.run(migration, database)
File "/opt/sentry/local/lib/python2.7/site-packages/south/migration/migrators.py", line 114, in run
return self.run_migration(migration, database)
File "/opt/sentry/local/lib/python2.7/site-packages/south/migration/migrators.py", line 84, in run_migration
migration_function()
File "/opt/sentry/local/lib/python2.7/site-packages/south/migration/migrators.py", line 60, in <lambda>
return (lambda: direction(orm))
File "/opt/sentry/local/lib/python2.7/site-packages/sentry/migrations/0135_auto__chg_field_project_team.py", line 12, in forwards
db.alter_column('sentry_project', 'team_id', self.gf('sentry.db.models.fields.FlexibleForeignKey')(to=orm['sentry.Team']))
File "/opt/sentry/local/lib/python2.7/site-packages/south/db/generic.py", line 47, in _cache_clear
return func(self, table, *args, **opts)
File "/opt/sentry/local/lib/python2.7/site-packages/south/db/generic.py", line 535, in alter_column
flatten(values),
File "/opt/sentry/local/lib/python2.7/site-packages/south/db/generic.py", line 282, in execute
cursor.execute(sql, params)
File "/opt/sentry/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/opt/sentry/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/opt/sentry/local/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: column "team_id" contains null values
(sentry)[root@ci] ~sentry #
@dcramer
Copy link
Copy Markdown

dcramer commented Jan 5, 2015

We will likely add a hotfix in for this, but as a simple resolution:

update team set owner_id = (select id from auth_user where is_superuser = true limit 1) where owner_id is null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment