Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update django 5.1 #197

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
python-version: ["3.10.x", "3.11.x", "3.12.x"]
django-version: ["4.2.x", "5.0.x"]
django-version: ["5.0.x", "5.1.x"]
env:
redis-version: "6.2"
pg-version: "15"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Django 4.1.7 on 2023-03-29 14:58

from django.db import migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand All @@ -10,12 +10,14 @@ class Migration(migrations.Migration):
]

operations = [
migrations.AlterIndexTogether(
name="dashblock",
index_together={("org", "is_active", "dashblock_type", "priority")},
migrations.AddIndex(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to adjust these old migrations to not use index_together as that throw the error
TypeError: 'class Meta' got invalid attribute(s): index_together

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's true.. Django 5.1 still has AlterIndexTogether for backwards compatibility - you just can't use index_together on a model

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I will step through the codes and see why that error is being thrown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to squash migrations before moving to 5.1 so that no index_together is used in historical migrations
https://docs.djangoproject.com/en/5.1/releases/4.2/#index-together-option-is-deprecated-in-favor-of-indexes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rowanseymour even with squashing the migrations we still need to adjust them to not use index_together

19dc98f

No other solution has been provided even on the tickets

https://code.djangoproject.com/ticket/35679

https://code.djangoproject.com/ticket/34856

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in our case we can just even skip the squash migrations and just adjust the past migrations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And editing the squashed migrations or existing migrations is what is suggested by https://code.djangoproject.com/ticket/34525#comment:17

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh... ok then sorry I was wrong about that.. I think go ahead and manually tweak old migrations if that's the easiest way forward

model_name="dashblock",
index=models.Index(
fields=["org", "is_active", "dashblock_type", "priority"], name="dashblocks__org_id_024805_idx"
),
),
migrations.AlterIndexTogether(
name="dashblocktype",
index_together={("slug", "name")},
migrations.AddIndex(
model_name="dashblocktype",
index=models.Index(fields=["slug", "name"], name="dashblocks__slug_c0c6c6_idx"),
),
]
8 changes: 4 additions & 4 deletions dash/orgs/migrations/0031_alter_orgbackend_index_together.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Django 4.1.7 on 2023-03-29 13:57

from django.db import migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand All @@ -9,8 +9,8 @@ class Migration(migrations.Migration):
]

operations = [
migrations.AlterIndexTogether(
name="orgbackend",
index_together={("org", "is_active", "slug")},
migrations.AddIndex(
model_name="orgbackend",
index=models.Index(fields=["org", "is_active", "slug"], name="orgs_orgbac_org_id_607508_idx"),
),
]
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repository = "http://github.com/rapidpro/dash"

[tool.poetry.dependencies]
python = "^3.10"
Django = ">= 4.2.14, < 5.1"
Django = ">= 5.0.8, < 5.2"
celery = "^5.1"
django-compressor = "^4.0"
django-redis = "^5.2.0"
Expand Down