Skip to content

Commit 971d94a

Browse files
authored
Upgrade to Django 5.x (#12104)
Upgrade our code base to Django 5.2 - `django-safemigrate` had to be upgraded: you will find _a lot of_ changes like `Safe.before_deploy` -> `Safe.before_deploy()` (all of them are in this particular commit: 4273e83) - I had to borrow `django.core.files.storage.get_storage_class` because it was deleted from Django 5.2 - `assertFormError` tests were updated to match the new signature - `django-celery-beat` and `django-storages` were upgraded - Update some old migrations referring to indexes to make them work Closes #12079 Closes #11505
1 parent b4bdd3d commit 971d94a

File tree

337 files changed

+406
-386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+406
-386
lines changed

docs/dev/migrations.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You can achieve this by following these steps:
4141
self.fields["new_field"].empty_value = False
4242
4343
#. Create the migration file (let's call this migration ``app 0001``),
44-
and mark it as ``Safe.before_deploy``.
44+
and mark it as ``Safe.before_deploy()``.
4545

4646
.. code-block:: python
4747
@@ -50,10 +50,10 @@ You can achieve this by following these steps:
5050
5151
5252
class Migration(migrations.Migration):
53-
safe = Safe.before_deploy
53+
safe = Safe.before_deploy()
5454
5555
#. Create a data migration to populate all null values of the new field with a proper value (let's call this migration ``app 0002``),
56-
and mark it as ``Safe.after_deploy``.
56+
and mark it as ``Safe.after_deploy()``.
5757

5858
.. code-block:: python
5959
@@ -66,14 +66,14 @@ You can achieve this by following these steps:
6666
6767
6868
class Migration(migrations.Migration):
69-
safe = Safe.after_deploy
69+
safe = Safe.after_deploy()
7070
7171
operations = [
7272
migrations.RunPython(migrate),
7373
]
7474
7575
#. After the deploy has been completed, create a new migration to set the field as non-nullable (let's call this migration ``app 0003``).
76-
Run this migration on a new deploy, you can mark it as ``Safe.before_deploy`` or ``Safe.always``.
76+
Run this migration on a new deploy, you can mark it as ``Safe.before_deploy()`` or ``Safe.always()``.
7777
#. Remove any handling of the null case from the code.
7878

7979
At the end, the deploy should look like this:
@@ -102,7 +102,7 @@ You can achieve this by following these steps:
102102
field_to_delete = models.CharField(max_length=100, null=True, blank=True)
103103
104104
#. Create the migration file (let's call this migration ``app 0001``),
105-
and mark it as ``Safe.before_deploy``.
105+
and mark it as ``Safe.before_deploy()``.
106106

107107
.. code-block:: python
108108
@@ -111,10 +111,10 @@ You can achieve this by following these steps:
111111
112112
113113
class Migration(migrations.Migration):
114-
safe = Safe.before_deploy
114+
safe = Safe.before_deploy()
115115
116116
#. Create a migration to remove the field from the database (let's call this migration ``app 0002``),
117-
and mark it as ``Safe.after_deploy``.
117+
and mark it as ``Safe.after_deploy()``.
118118

119119
.. code-block:: python
120120
@@ -123,7 +123,7 @@ You can achieve this by following these steps:
123123
124124
125125
class Migration(migrations.Migration):
126-
safe = Safe.after_deploy
126+
safe = Safe.after_deploy()
127127
128128
At the end, the deploy should look like this:
129129

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ filterwarnings =
2222
ignore:DateTimeField .* received a naive datetime .* while time zone support is active:RuntimeWarning
2323
ignore:.*:DeprecationWarning
2424

25-
ignore:.*:django.utils.deprecation.RemovedInDjango50Warning
25+
ignore:.*:django.utils.deprecation.RemovedInDjango60Warning
2626
ignore:.*:elasticsearch.exceptions.ElasticsearchWarning
2727
ignore:.*:PendingDeprecationWarning

readthedocs/analytics/migrations/0001_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class Migration(migrations.Migration):
11-
safe = Safe.after_deploy
11+
safe = Safe.after_deploy()
1212
initial = True
1313

1414
dependencies = [

readthedocs/analytics/migrations/0002_track_status_code.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class Migration(migrations.Migration):
9-
safe = Safe.after_deploy
9+
safe = Safe.after_deploy()
1010
dependencies = [
1111
("builds", "0041_track_task_id"),
1212
("projects", "0087_use_booleanfield_null"),

readthedocs/analytics/migrations/0003_remove_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class Migration(migrations.Migration):
10-
safe = Safe.after_deploy
10+
safe = Safe.after_deploy()
1111
dependencies = [
1212
("analytics", "0002_track_status_code"),
1313
]

readthedocs/analytics/migrations/0004_merge_duplicate_records.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def forwards_func(apps, schema_editor):
2929

3030

3131
class Migration(migrations.Migration):
32-
safe = Safe.after_deploy
32+
safe = Safe.after_deploy()
3333
dependencies = [
3434
("analytics", "0003_remove_index"),
3535
]

readthedocs/analytics/migrations/0005_add_unique_constraint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("analytics", "0004_merge_duplicate_records"),
1111
]

readthedocs/analytics/migrations/0006_alter_pageview_id.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("analytics", "0005_add_unique_constraint"),
1111
]

readthedocs/analytics/migrations/0007_index_on_pageview_date.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class Migration(migrations.Migration):
10-
safe = Safe.after_deploy
10+
safe = Safe.after_deploy()
1111
dependencies = [
1212
("analytics", "0006_alter_pageview_id"),
1313
]

readthedocs/api/v2/migrations/0001_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class Migration(migrations.Migration):
9-
safe = Safe.after_deploy
9+
safe = Safe.after_deploy()
1010
initial = True
1111

1212
dependencies = [

readthedocs/audit/migrations/0001_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class Migration(migrations.Migration):
12-
safe = Safe.after_deploy
12+
safe = Safe.after_deploy()
1313
initial = True
1414

1515
dependencies = [

readthedocs/audit/migrations/0002_add_organization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class Migration(migrations.Migration):
10-
safe = Safe.after_deploy
10+
safe = Safe.after_deploy()
1111
dependencies = [
1212
("organizations", "0006_add_assets_cleaned"),
1313
("audit", "0001_initial"),

readthedocs/audit/migrations/0003_update_ordering.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class Migration(migrations.Migration):
7-
safe = Safe.after_deploy
7+
safe = Safe.after_deploy()
88
dependencies = [
99
("audit", "0002_add_organization"),
1010
]

readthedocs/audit/migrations/0004_change_ip_field_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("audit", "0003_update_ordering"),
1111
]

readthedocs/audit/migrations/0005_migrate_ip_field_values.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def forwards_func(apps, schema_editor):
2020

2121

2222
class Migration(migrations.Migration):
23-
safe = Safe.after_deploy
23+
safe = Safe.after_deploy()
2424
dependencies = [
2525
("audit", "0004_change_ip_field_type"),
2626
]

readthedocs/audit/migrations/0006_add_download_action.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("audit", "0005_migrate_ip_field_values"),
1111
]

readthedocs/audit/migrations/0007_auditlog_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("audit", "0006_add_download_action"),
1111
]

readthedocs/audit/migrations/0008_alter_auditlog_action.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("audit", "0007_auditlog_data"),
1111
]

readthedocs/builds/migrations/0001_initial.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class Migration(migrations.Migration):
10-
safe = Safe.always
10+
safe = Safe.always()
1111
dependencies = [
1212
("projects", "0001_initial"),
1313
("taggit", "0001_initial"),
@@ -247,8 +247,4 @@ class Migration(migrations.Migration):
247247
name="version",
248248
unique_together={("project", "slug")},
249249
),
250-
migrations.AlterIndexTogether(
251-
name="build",
252-
index_together={("version", "state", "type")},
253-
),
254250
]

readthedocs/builds/migrations/0002_build_command_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class Migration(migrations.Migration):
9-
safe = Safe.after_deploy
9+
safe = Safe.after_deploy()
1010
dependencies = [
1111
("builds", "0001_initial"),
1212
]

readthedocs/builds/migrations/0003_add-cold-storage.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0002_build_command_initial"),
1111
]

readthedocs/builds/migrations/0004_add-apiversion-proxy-model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class Migration(migrations.Migration):
7-
safe = Safe.after_deploy
7+
safe = Safe.after_deploy()
88
dependencies = [
99
("builds", "0003_add-cold-storage"),
1010
]

readthedocs/builds/migrations/0005_remove-version-alias.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class Migration(migrations.Migration):
10-
safe = Safe.always
10+
safe = Safe.always()
1111
dependencies = [
1212
("builds", "0004_add-apiversion-proxy-model"),
1313
]

readthedocs/builds/migrations/0006_add_config_field.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0005_remove-version-alias"),
1111
]

readthedocs/builds/migrations/0007_add-automation-rules.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
class Migration(migrations.Migration):
10-
safe = Safe.after_deploy
10+
safe = Safe.after_deploy()
1111
dependencies = [
1212
("projects", "0042_increase_env_variable_value_max_length"),
1313
("contenttypes", "0002_remove_content_type_name"),

readthedocs/builds/migrations/0008_remove-version-tags.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class Migration(migrations.Migration):
7-
safe = Safe.after_deploy
7+
safe = Safe.after_deploy()
88
dependencies = [
99
("builds", "0007_add-automation-rules"),
1010
]

readthedocs/builds/migrations/0009_added_external_version_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0008_remove-version-tags"),
1111
]

readthedocs/builds/migrations/0010_add-description-field-to-automation-rule.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0009_added_external_version_type"),
1111
]

readthedocs/builds/migrations/0011_version-media-availability.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0010_add-description-field-to-automation-rule"),
1111
]

readthedocs/builds/migrations/0012_add-predefined-match-arg-field.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0011_version-media-availability"),
1111
]

readthedocs/builds/migrations/0013_version_documentation_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0012_add-predefined-match-arg-field"),
1111
]

readthedocs/builds/migrations/0014_migrate-doctype-from-project-to-version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def forwards_func(apps, schema_editor):
1818

1919

2020
class Migration(migrations.Migration):
21-
safe = Safe.after_deploy
21+
safe = Safe.after_deploy()
2222
dependencies = [
2323
("builds", "0013_version_documentation_type"),
2424
]

readthedocs/builds/migrations/0015_uploading_build_state.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0014_migrate-doctype-from-project-to-version"),
1111
]

readthedocs/builds/migrations/0016_add_mkdocs_html_doctype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
class Migration(migrations.Migration):
8-
safe = Safe.after_deploy
8+
safe = Safe.after_deploy()
99
dependencies = [
1010
("builds", "0015_uploading_build_state"),
1111
]

0 commit comments

Comments
 (0)