[Chore] Upgrade Django #93480

Closed
opened 2021-11-29 15:55:48 +01:00 by Anna Sirota · 2 comments
Owner

Django 3.0 is not longer supported, upgrade everything to 3.2.

    • Blender Studio {6a85c942}
    • Blender Development Fund {b15c7b2a0}
    • Blender Conference {8a7a8a8220fb7}
    • Blender ID {6f1f100df}

Issues encountered [wip]

Django migrations unable to find Wagtail constraints in DevFund's DB

pgloader migrated unique constraints as indices, so manage.py migrate failed with the following:

$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, blender_fund_main, blender_id_oauth_client, blender_notes, contenttypes, looper, sessions, sites, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers
Running migrations:
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying looper.0076_order_external_reference... OK
  Applying wagtailadmin.0002_admin... OK
  Applying wagtailadmin.0003_admin_managed... OK
  Applying wagtailcore.0046_site_name_remove_null... OK
  Applying wagtailcore.0047_add_workflow_models... OK
  Applying wagtailcore.0048_add_default_workflows... OK
  Applying wagtailcore.0049_taskstate_finished_by... OK
  Applying wagtailcore.0050_workflow_rejected_to_needs_changes... OK
  Applying wagtailcore.0051_taskstate_comment... OK
  Applying wagtailcore.0052_pagelogentry... OK
  Applying wagtailcore.0053_locale_model... OK
  Applying wagtailcore.0054_initial_locale... OK
  Applying wagtailcore.0055_page_locale_fields... OK
  Applying wagtailcore.0056_page_locale_fields_populate... OK
  Applying wagtailcore.0057_page_locale_fields_notnull... OK
  Applying wagtailcore.0058_page_alias_of... OK
  Applying wagtailcore.0059_apply_collection_ordering... OK
  Applying wagtailcore.0060_fix_workflow_unique_constraint... OK
  Applying wagtailcore.0061_change_promote_tab_helpt_text_and_verbose_names... OK
  Applying wagtailcore.0062_comment_models_and_pagesubscription... OK
  Applying wagtailcore.0063_modellogentry... OK
  Applying wagtailcore.0064_log_timestamp_indexes... OK
  Applying wagtailcore.0065_log_entry_uuid... OK
  Applying wagtailcore.0066_collection_management_permissions... OK
  Applying wagtaildocs.0011_add_choose_permissions... OK
  Applying wagtaildocs.0012_uploadeddocument... OK
  Applying wagtailembeds.0006_add_embed_hash... OK
  Applying wagtailembeds.0007_populate_hash... OK
  Applying wagtailembeds.0008_allow_long_urls...Traceback (most recent call last):
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedObject: constraint "idx_11388500_wagtailembeds_embed_url_max_width_8a2922d8_uniq" of relation "wagtailembeds_embed" does not exist


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/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 246, in handle
    fake_initial=fake_initial,
  File "/home/railla/.envs/blender-dev-fund/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/railla/.envs/blender-dev-fund/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/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 531, in database_forwards
    getattr(new_model._meta, self.option_name, set()),
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 415, in alter_unique_together
    self._delete_composed_index(model, fields, {'unique': True}, self.sql_delete_unique)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 456, in _delete_composed_index
    self.execute(self._delete_constraint_sql(sql, model, constraint_names[0]))
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 145, in execute
    cursor.execute(sql, params)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: constraint "idx_11388500_wagtailembeds_embed_url_max_width_8a2922d8_uniq" of relation "wagtailembeds_embed" does not exist

The following appeared to have helped (at least locally):

blender_fund=# SET search_path TO blender_fund;
SET
blender_fund=# begin transaction;
BEGIN
blender_fund=*# DROP INDEX "idx_11388500_wagtailembeds_embed_url_max_width_8a2922d8_uniq";
DROP INDEX
blender_fund=*# ALTER TABLE wagtailembeds_embed ADD CONSTRAINT wagtailembeds_embed_url_max_width_8a2922d8_uniq UNIQUE(url, max_width);
ALTER TABLE
blender_fund=*# commit;
COMMIT
Django 3.0 is not longer supported, upgrade everything to 3.2. - - [x] Blender Studio {6a85c942} - - [x] Blender Development Fund {b15c7b2a0} - - [x] Blender Conference {8a7a8a8220fb7} - - [x] Blender ID {6f1f100df} ### Issues encountered [wip] **Django migrations unable to find Wagtail constraints in DevFund's DB** `pgloader` migrated unique constraints as indices, so `manage.py migrate` failed with the following: ``` $ python manage.py migrate Operations to perform: Apply all migrations: admin, auth, blender_fund_main, blender_id_oauth_client, blender_notes, contenttypes, looper, sessions, sites, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers Running migrations: Applying auth.0012_alter_user_first_name_max_length... OK Applying looper.0076_order_external_reference... OK Applying wagtailadmin.0002_admin... OK Applying wagtailadmin.0003_admin_managed... OK Applying wagtailcore.0046_site_name_remove_null... OK Applying wagtailcore.0047_add_workflow_models... OK Applying wagtailcore.0048_add_default_workflows... OK Applying wagtailcore.0049_taskstate_finished_by... OK Applying wagtailcore.0050_workflow_rejected_to_needs_changes... OK Applying wagtailcore.0051_taskstate_comment... OK Applying wagtailcore.0052_pagelogentry... OK Applying wagtailcore.0053_locale_model... OK Applying wagtailcore.0054_initial_locale... OK Applying wagtailcore.0055_page_locale_fields... OK Applying wagtailcore.0056_page_locale_fields_populate... OK Applying wagtailcore.0057_page_locale_fields_notnull... OK Applying wagtailcore.0058_page_alias_of... OK Applying wagtailcore.0059_apply_collection_ordering... OK Applying wagtailcore.0060_fix_workflow_unique_constraint... OK Applying wagtailcore.0061_change_promote_tab_helpt_text_and_verbose_names... OK Applying wagtailcore.0062_comment_models_and_pagesubscription... OK Applying wagtailcore.0063_modellogentry... OK Applying wagtailcore.0064_log_timestamp_indexes... OK Applying wagtailcore.0065_log_entry_uuid... OK Applying wagtailcore.0066_collection_management_permissions... OK Applying wagtaildocs.0011_add_choose_permissions... OK Applying wagtaildocs.0012_uploadeddocument... OK Applying wagtailembeds.0006_add_embed_hash... OK Applying wagtailembeds.0007_populate_hash... OK Applying wagtailembeds.0008_allow_long_urls...Traceback (most recent call last): File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedObject: constraint "idx_11388500_wagtailembeds_embed_url_max_width_8a2922d8_uniq" of relation "wagtailembeds_embed" does not exist 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/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/base.py", line 89, in wrapped res = handle_func(*args, **kwargs) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 246, in handle fake_initial=fake_initial, File "/home/railla/.envs/blender-dev-fund/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/railla/.envs/blender-dev-fund/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/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/migrations/executor.py", line 227, in apply_migration state = migration.apply(state, schema_editor) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/migrations/migration.py", line 126, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 531, in database_forwards getattr(new_model._meta, self.option_name, set()), File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 415, in alter_unique_together self._delete_composed_index(model, fields, {'unique': True}, self.sql_delete_unique) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 456, in _delete_composed_index self.execute(self._delete_constraint_sql(sql, model, constraint_names[0])) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 145, in execute cursor.execute(sql, params) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 98, in execute return super().execute(sql, params) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/home/railla/.envs/blender-dev-fund/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: constraint "idx_11388500_wagtailembeds_embed_url_max_width_8a2922d8_uniq" of relation "wagtailembeds_embed" does not exist ``` The following appeared to have helped (at least locally): ``` blender_fund=# SET search_path TO blender_fund; SET blender_fund=# begin transaction; BEGIN blender_fund=*# DROP INDEX "idx_11388500_wagtailembeds_embed_url_max_width_8a2922d8_uniq"; DROP INDEX blender_fund=*# ALTER TABLE wagtailembeds_embed ADD CONSTRAINT wagtailembeds_embed_url_max_width_8a2922d8_uniq UNIQUE(url, max_width); ALTER TABLE blender_fund=*# commit; COMMIT ```
Author
Owner

Added subscriber: @railla

Added subscriber: @railla
Anna Sirota self-assigned this 2021-12-07 11:13:03 +01:00
Author
Owner

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/conference-website#93480
No description provided.