Skip to content
New issue

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

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

Already on GitHub? # to your account

[PR #2119/99d48bd7 backport][0.24] Fix the uniquenes constraint migration #2120

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
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