diff --git a/CHANGES/2118.bugfix b/CHANGES/2118.bugfix new file mode 100644 index 000000000..742f47a5f --- /dev/null +++ b/CHANGES/2118.bugfix @@ -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. diff --git a/pulp_ansible/app/migrations/0059_collectionversion_unique_sha256.py b/pulp_ansible/app/migrations/0059_collectionversion_unique_sha256.py index 62fa1fee7..af2e2fa05 100644 --- a/pulp_ansible/app/migrations/0059_collectionversion_unique_sha256.py +++ b/pulp_ansible/app/migrations/0059_collectionversion_unique_sha256.py @@ -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",