Skip to content

Commit

Permalink
Delete resources so reverse migrations will work (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding authored Aug 21, 2024
1 parent 7811429 commit 1100435
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def reset_service_id(apps, schema_editor):
Resource.objects.all().update(service_id=ServiceID.objects.first().id)


def revert_post_migrate(apps, schema_editor):
"Resources are created post-migrate, and prior model is incompatible anyway, so delete them"
Resource = apps.get_model("dab_resource_registry", "Resource")
Resource.objects.all().delete()


class Migration(migrations.Migration):

dependencies = [
Expand All @@ -30,7 +36,7 @@ class Migration(migrations.Migration):
),
migrations.RunPython(
code=reset_service_id,
reverse_code=migrations.RunPython.noop
reverse_code=revert_post_migrate
),
migrations.AlterField(
model_name='resource',
Expand Down

0 comments on commit 1100435

Please sign in to comment.