Skip to content

Commit

Permalink
Fix the uniquenes constraint migration
Browse files Browse the repository at this point in the history
fixes #2118

(cherry picked from commit 99d48bd)
  • Loading branch information
mdellweg committed Feb 18, 2025
1 parent 4125480 commit 59a3e71
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES/2118.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a migration that was failing when upgrading on a system that was on 0.23.0 at one point in time.
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@
class Migration(migrations.Migration):

dependencies = [
('ansible', '0058_fix_0056_regression'),
('core', '0110_apiappstatus'),
("ansible", "0058_fix_0056_regression"),
("core", "0110_apiappstatus"),
]

operations = [
RequireVersion("ansible", "0.23.0"),
migrations.AlterField(
model_name='collectionversion',
name='sha256',
model_name="collectionversion",
name="sha256",
field=models.CharField(db_index=True, max_length=64, null=False),
),
# ---
# The previous fix in migration 0058 did not do the job.
# But we can just drop the contstraint if present.
# And this is only necessary if this migration failed to apply before.
migrations.RunSQL(
sql="ALTER TABLE ansible_collectionversion DROP CONSTRAINT IF EXISTS "
"ansible_collectionversion_sha256_a4d120ab_uniq",
reverse_sql="",
elidable=True,
),
# ---
migrations.AlterUniqueTogether(
name='collectionversion',
unique_together={('sha256',)},
name="collectionversion",
unique_together={("sha256",)},
),
migrations.RemoveConstraint(
model_name="collectionversion",
Expand Down

0 comments on commit 59a3e71

Please # to comment.