CI build failing but local builds pass

539 views
Skip to first unread message

Ajat Prabha

unread,
Aug 1, 2018, 2:17:16 PM8/1/18
to Django users
Hi,
I'm working on a hobby project and the issue I'm facing is that the CI build is failing and I'm not sure why is this happening.
The only difference is that I updated Django to v2.1 after the last successful build. However, when I try to make migrations and migrate on my local machine, it runs smoothly.

Here's the log:
python3 manage.py migrate
/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
Operations to perform:
Apply all migrations: accounts, admin, auth, contenttypes, courses, sessions, social_django, study_material
Running migrations:
Applying accounts.0001_initial... OK
Applying courses.0001_initial... OK
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying accounts.0002_auto_20180801_1737... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... 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 auth.0009_alter_user_last_name_max_length... OK
Applying sessions.0001_initial... OK
Applying social_django.0001_initial... OK
Applying social_django.0002_add_related_name...Traceback (most recent call last):
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: syntax error at or near "WITH ORDINALITY"
LINE 6: FROM unnest(c.conkey) WITH ORDINALITY co...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 203, in handle
fake_initial=fake_initial,
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 216, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 523, in alter_field
old_db_params, new_db_params, strict)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/postgresql/schema.py", line 122, in _alter_field
new_db_params, strict,
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 531, in _alter_field
fk_names = self._constraint_names(model, [old_field.column], foreign_key=True)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 1027, in _constraint_names
constraints = self.connection.introspection.get_constraints(cursor, model._meta.db_table)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/postgresql/introspection.py", line 158, in get_constraints
""", ["public", table_name])
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: syntax error at or near "WITH ORDINALITY"
LINE 6: FROM unnest(c.conkey) WITH ORDINALITY co...
^

The command "python3 manage.py migrate" exited with 1.
Can someone shed some light here?
Thanks!

Ajat Prabha

unread,
Aug 1, 2018, 3:02:34 PM8/1/18
to Django users
The issue is fixed now, it happened because Travis used PostgreSQL v9.2 by default and Django v2.1 works with v9.4+ (changelog)

Ismail Sunni

unread,
Aug 3, 2018, 7:37:26 AM8/3/18
to Django users
Thanks so much. I got this problem also.
Reply all
Reply to author
Forward
0 new messages