{"action":"created","issue":{"url":"https://api.github.com/repos/divio/django-cms/issues/6338","repository_url":"https://api.github.com/repos/divio/django-cms","labels_url":"https://api.github.com/repos/divio/django-cms/issues/6338/labels{/name}","comments_url":"https://api.github.com/repos/divio/django-cms/issues/6338/comments","events_url":"https://api.github.com/repos/divio/django-cms/issues/6338/events","html_url":"https://github.com/divio/django-cms/issues/6338","id":316390702,"number":6338,"title":"Forgein key error when upgrading from 3.3.0 to 3.5.x","user":{"login":"AngellusMortis","id":490848,"avatar_url":"https://avatars2.githubusercontent.com/u/490848?v=4","gravatar_id":"","url":"https://api.github.com/users/AngellusMortis","html_url":"https://github.com/AngellusMortis","followers_url":"https://api.github.com/users/AngellusMortis/followers","following_url":"https://api.github.com/users/AngellusMortis/following{/other_user}","gists_url":"https://api.github.com/users/AngellusMortis/gists{/gist_id}","starred_url":"https://api.github.com/users/AngellusMortis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AngellusMortis/subscriptions","organizations_url":"https://api.github.com/users/AngellusMortis/orgs","repos_url":"https://api.github.com/users/AngellusMortis/repos","events_url":"https://api.github.com/users/AngellusMortis/events{/privacy}","received_events_url":"https://api.github.com/users/AngellusMortis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-20T19:49:03Z","updated_at":"2018-04-23T16:36:19Z","closed_at":null,"author_association":"NONE","body":"### Summary\r\nAs part of our upgrade of one of our sites, we upgraded from Django 1.8.x to Django 1.11.x, Django CMS 3.3.0 to Django CMS 3.5.x, and MySQL 14.14 to MariaDB 15.1. The cms.0018_pagenode migration is failing due to a foreign key issue. \r\n\r\n### Expected behavior\r\ncms.0018_pagenode database migration to go through fine.\r\n\r\n### Actual behavior\r\ncms.0018_pagenode database migration fails.\r\n\r\nError from Django:\r\n```\r\nApplying cms.0018_pagenode...Traceback (most recent call last):\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 162, in _run_module_as_main\r\n    \"__main__\", fname, loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/srv/thesite/web/thesite/manage.py\", line 15, in <module>\r\n    main()\r\n  File \"/srv/thesite/web/thesite/manage.py\", line 11, in main\r\n    execute_from_command_line(sys.argv)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/core/management/__init__.py\", line 364, in execute_from_command_line\r\n    utility.execute()\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/core/management/__init__.py\", line 356, in execute\r\n    self.fetch_command(subcommand).run_from_argv(self.argv)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/core/management/base.py\", line 283, in run_from_argv\r\n    self.execute(*args, **cmd_options)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/core/management/base.py\", line 330, in execute\r\n    output = self.handle(*args, **options)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/core/management/commands/migrate.py\", line 204, in handle\r\n    fake_initial=fake_initial,\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 115, in migrate\r\n    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 145, in _migrate_all_forwards\r\n    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 244, in apply_migration\r\n    state = migration.apply(state, schema_editor)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/backends/base/schema.py\", line 93, in __exit__\r\n    self.execute(sql)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/backends/base/schema.py\", line 120, in execute\r\n    cursor.execute(sql, params)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/backends/utils.py\", line 64, in execute\r\n    return self.cursor.execute(sql, params)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/utils.py\", line 94, in __exit__\r\n    six.reraise(dj_exc_type, dj_exc_value, traceback)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/backends/utils.py\", line 64, in execute\r\n    return self.cursor.execute(sql, params)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py\", line 101, in execute\r\n    return self.cursor.execute(query, args)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/MySQLdb/cursors.py\", line 205, in execute\r\n    self.errorhandler(self, exc, value)\r\n  File \"/srv/thesite/venv/lib/python2.7/site-packages/MySQLdb/connections.py\", line 36, in defaulterrorhandler\r\n    raise errorclass, errorvalue\r\ndjango.db.utils.OperationalError: (1005, \"Can't create table 'thesite.#sql-5a7_428' (errno: 150)\")\r\n```\r\n\r\nError from MySQL (generated from `SHOW ENGINE INNODB STATUS`):\r\n```\r\n------------------------\r\nLATEST FOREIGN KEY ERROR\r\n------------------------\r\n180420 15:30:30 Error in foreign key constraint of table `thesite`.`cms_treenode`:\r\nAlter  table `thesite`.`cms_treenode` with foreign key constraint failed. Referenced table `thesite`.`d\r\njango_site` not found in the data dictionary near ' FOREIGN KEY (`site_id`) REFERENCES `django_site` (`\r\nid`)'.\r\n```\r\n\r\n\r\n### Environment\r\n* Python version: 2.7.5\r\n* Django version: 1.11.11\r\n* django CMS version: 3.5.2 (happens on 3.5.0 and 3.5.1 as well)\r\n"},"comment":{"url":"https://api.github.com/repos/divio/django-cms/issues/comments/383640361","html_url":"https://github.com/divio/django-cms/issues/6338#issuecomment-383640361","issue_url":"https://api.github.com/repos/divio/django-cms/issues/6338","id":383640361,"user":{"login":"AngellusMortis","id":490848,"avatar_url":"https://avatars2.githubusercontent.com/u/490848?v=4","gravatar_id":"","url":"https://api.github.com/users/AngellusMortis","html_url":"https://github.com/AngellusMortis","followers_url":"https://api.github.com/users/AngellusMortis/followers","following_url":"https://api.github.com/users/AngellusMortis/following{/other_user}","gists_url":"https://api.github.com/users/AngellusMortis/gists{/gist_id}","starred_url":"https://api.github.com/users/AngellusMortis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AngellusMortis/subscriptions","organizations_url":"https://api.github.com/users/AngellusMortis/orgs","repos_url":"https://api.github.com/users/AngellusMortis/repos","events_url":"https://api.github.com/users/AngellusMortis/events{/privacy}","received_events_url":"https://api.github.com/users/AngellusMortis/received_events","type":"User","site_admin":false},"created_at":"2018-04-23T16:36:19Z","updated_at":"2018-04-23T16:36:19Z","author_association":"NONE","body":"Yes. I have verified the django_site table appears before and after the migrations run. "}}
{"actor":{"display_login":"AngellusMortis"}}