Opened 7 years ago
Closed 7 years ago
#28736 closed Bug (invalid)
Database migration fails with postgresql 8.x with rest_framework.authtoken
Reported by: | Kester Habermann | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Normal | Keywords: | introspection.py postgresql 8.x |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
manage.py migrate fails when these are added to INSTALLED_APPS:
'rest_framework',
'rest_framework.authtoken',
The problem is present when using postgresql-8.4.20 (RHEL 6)
Django==1.11.6
djangorestframework==3.7.1
psycopg2==2.6.1
Python 2.7
The problem first appeared in Django==1.11.2 and is present in 1.11.6, too. It works with Django==1.11.1. This is due to a change in this file:
$VIRTUAL_ENV/lib/python2.7/site-packages/django/db/backends/postgresql/introspection.py
If the file from Django==1.11.1 is copied to Django==1.11.6, the "migrate" works again.
The problem is not present with postgresql-9.2.21 (RHEL 7.4).
How to reproduce the problem:
1) create new project with django-admin startproject mysite
2) edit mysite/mysite/settings.py
add to INSTALLED_APPS = [ ]:
'rest_framework',
'rest_framework.authtoken',
change DATABASES
to a PostgreSQL 8.4.20 database.
3) python manage.py migrate
Full output
python manage.py migrate Operations to perform: Apply all migrations: admin, auth, authtoken, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying authtoken.0001_initial... OK Applying authtoken.0002_auto_20160226_1747...Traceback (most recent call last): File "./manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line utility.execute() File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv self.execute(*args, **cmd_options) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute output = self.handle(*args, **options) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle fake_initial=fake_initial, File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 215, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 515, in alter_field old_db_params, new_db_params, strict) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/postgresql/schema.py", line 112, in _alter_field new_db_params, strict, File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 524, in _alter_field fk_names = self._constraint_names(model, [old_field.column], foreign_key=True) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 989, in _constraint_names constraints = self.connection.introspection.get_constraints(cursor, model._meta.db_table) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/postgresql/introspection.py", line 233, in get_constraints """, [table_name]) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/utils.py", line 80, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/home/khaberma/work/python/django-11.1/venv-django-1.11.2/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: syntax error at or near "ORDER" LINE 3: indexname, array_agg(attname ORDER BY rnum),...
Change History (2)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
As per the Databases docs for Django 1.11, "Django supports PostgreSQL 9.3 and higher."
From the Django 1.8 release notes, "The end of upstream support periods was reached in July 2014 for PostgreSQL 8.4. As a consequence, Django 1.8 sets 9.0 as the minimum PostgreSQL version it officially supports."