After upgrade sentry from pip to version 8.20 (from 8.19), I run SENTRY_CONF=/etc/sentry /www/sentry/bin/sentry upgrade and got following error:
(sentry) [root@sentry ~]# SENTRY_CONF=/etc/sentry /www/sentry/bin/sentry upgrade
Syncing...
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Synced:
> django.contrib.admin
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.messages
> django.contrib.sessions
> django.contrib.sites
> django.contrib.staticfiles
> crispy_forms
> debug_toolbar
> raven.contrib.django.raven_compat
> rest_framework
> sentry.plugins.sentry_interface_types
> sentry.plugins.sentry_mail
> sentry.plugins.sentry_urls
> sentry.plugins.sentry_useragents
> sentry.plugins.sentry_webhooks
> sudo
> south
> sentry_plugins.slack
Not synced (use migrations):
- sentry
- sentry.nodestore
- sentry.search
- social_auth
- sentry_plugins.jira_ac
- sentry_plugins.hipchat_ac
(use ./manage.py migrate to migrate these)
Running migrations for sentry:
- Migrating forwards to 0351_backfillemail.
> sentry:0345_add_citext
FATAL ERROR - The following SQL query failed: CREATE EXTENSION IF NOT EXISTS citext
The error was: OperationalError('could not open extension control file "/usr/share/pgsql/extension/citext.control": No such file or directory\n',)
SQL: CREATE EXTENSION IF NOT EXISTS citext
Error in migration: sentry:0345_add_citext
None
09:02:50 [INFO] sentry.utils.raven.SentryInternalClient: Not capturing exception due to filters: <class 'django.db.utils.OperationalError'>
Traceback (most recent call last):
File "/www/sentry/bin/sentry", line 11, in <module>
sys.exit(main())
File "/www/sentry/lib/python2.7/site-packages/sentry/runner/__init__.py", line 160, in main
cli(prog_name=get_prog(), obj={}, max_content_width=100)
File "/www/sentry/lib/python2.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/www/sentry/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/www/sentry/lib/python2.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/www/sentry/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/sentry/runner/decorators.py", line 36, in inner
return ctx.invoke(f, *args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/sentry/runner/commands/upgrade.py", line 67, in upgrade
_upgrade(not noinput, traceback, verbosity, not no_repair)
File "/www/sentry/lib/python2.7/site-packages/sentry/runner/commands/upgrade.py", line 29, in _upgrade
verbosity=verbosity,
File "/www/sentry/lib/python2.7/site-packages/django/core/management/__init__.py", line 159, in call_command
return klass.execute(*args, **defaults)
File "/www/sentry/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/www/sentry/lib/python2.7/site-packages/south/management/commands/migrate.py", line 115, in handle
ignore_ghosts=ignore_ghosts,
File "/www/sentry/lib/python2.7/site-packages/south/migration/__init__.py", line 234, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/www/sentry/lib/python2.7/site-packages/south/migration/migrators.py", line 255, in migrate_many
result = migrator.__class__.migrate_many(migrator, target, migrations, database)
File "/www/sentry/lib/python2.7/site-packages/south/migration/migrators.py", line 330, in migrate_many
result = self.migrate(migration, database)
File "/www/sentry/lib/python2.7/site-packages/south/migration/migrators.py", line 131, in migrate
result = self.run(migration, database)
File "/www/sentry/lib/python2.7/site-packages/south/migration/migrators.py", line 113, in run
return self.run_migration(migration, database)
File "/www/sentry/lib/python2.7/site-packages/south/migration/migrators.py", line 84, in run_migration
migration_function()
File "/www/sentry/lib/python2.7/site-packages/south/migration/migrators.py", line 60, in <lambda>
return (lambda: direction(orm))
File "/www/sentry/lib/python2.7/site-packages/sentry/south_migrations/0345_add_citext.py", line 13, in forwards
self._forwards(orm)
File "/www/sentry/lib/python2.7/site-packages/sentry/south_migrations/0345_add_citext.py", line 21, in _forwards
db.execute('CREATE EXTENSION IF NOT EXISTS citext')
File "/www/sentry/lib/python2.7/site-packages/south/db/generic.py", line 284, in execute
cursor.execute(sql, params)
File "/www/sentry/lib/python2.7/site-packages/raven/contrib/django/client.py", line 112, in execute
return real_execute(self, sql, params)
File "/www/sentry/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/www/sentry/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/www/sentry/lib/python2.7/site-packages/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)
File "/www/sentry/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 80, in inner
raise_the_exception(self.db, e)
File "/www/sentry/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 78, in inner
return func(self, *args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 22, in inner
return func(self, *args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 101, in inner
six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
File "/www/sentry/lib/python2.7/site-packages/sentry/db/postgres/decorators.py", line 94, in inner
return func(self, sql, *args, **kwargs)
File "/www/sentry/lib/python2.7/site-packages/sentry/db/postgres/base.py", line 39, in execute
return self.cursor.execute(sql, params)
django.db.utils.OperationalError: OperationalError('could not open extension control file "/usr/share/pgsql/extension/citext.control": No such file or directory\n',)
SQL: CREATE EXTENSION IF NOT EXISTS citext
(sentry) [root@sentry ~]# postgres --version
postgres (PostgreSQL) 9.2.18
Okay guys, I just fixed this by installing postgresql-contrib package to the system (CentOS 7).
Had same issue even with postgresql-contrib installed on Ubuntu 16.04.3 LTS.
As solution I have added sentry user to superuser role for upgrade process
su postgres
psql
> alter role sentry superuser;
After upgrade I have removed access
> alter role sentry nosuperuser;
Can reproduce with postgresql96 installed on Centos 7.7. Installing postgresql96-contribdoesn't fix this, the superuser workaround worked.
Alternative solution to granting superuser permissions that is more friendly to automation is to manually enable extension for the database.
I'm using puppet and the puppetlabs-postgresql module, so for me the solution looks like this:
class { 'postgresql::server':
...
}
postgresql::server::db { 'sentry':
...
}
postgresql::server::extension { 'citext':
database => 'sentry'
}
exec { 'sentry upgrade --noinput':
...
require => Postgresql::Server::Extension['citext']
}
@Kentzo But even if the extension exists, the migration bails with permission denied.
What is the error?
Ah. Stupid me. I solved it. I had created the extension in the wrong database. Sorry
after install postgresql96-contrib sentry upgrade is ok
If your postgres is a docker container in a compose project, you can get your bash like this:
docker-compose exec postgres /bin/bash
Then follow @lenisko's code above.
Most helpful comment
Had same issue even with
postgresql-contribinstalled on Ubuntu 16.04.3 LTS.As solution I have added sentry user to superuser role for upgrade process
After upgrade I have removed access