diff --git a/prizetap/migrations/0079_fix_raffle_image_urls.py b/prizetap/migrations/0079_fix_raffle_image_urls.py new file mode 100644 index 0000000..7574063 --- /dev/null +++ b/prizetap/migrations/0079_fix_raffle_image_urls.py @@ -0,0 +1,32 @@ +# Generated by Django 4.0.4 on 2024-08-25 09:12 + +from django.db import migrations, models + + +def fix_raffle_images_prefix(apps, schema): + Raffle = apps.get_model("prizetap", "Raffle") + + raffles = Raffle.objects.all() + + for raffle in raffles: + if ( + raffle.image + and raffle.image.name + and raffle.image.name.startswith("https://imagedelivery.net") + ): + # split the url to get the image id + raffle.image.name = raffle.image.name.split("/")[-2] + raffle.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("tokenTap", "0078_alter_constraint_name"), + ] + + operations = [ + migrations.RunPython( + fix_raffle_images_prefix, reverse_code=migrations.RunPython.noop + ) + ] diff --git a/tokenTap/migrations/0065_fix_token_image_prefix.py b/tokenTap/migrations/0065_fix_token_image_prefix.py new file mode 100644 index 0000000..d1df6a4 --- /dev/null +++ b/tokenTap/migrations/0065_fix_token_image_prefix.py @@ -0,0 +1,40 @@ +# Generated by Django 4.0.4 on 2024-08-25 09:12 + +from django.db import migrations, models + + +def fix_token_images_prefix(apps, schema_editor): + TokenDistribution = apps.get_model("tokenTap", "TokenDistribution") + + tokens = TokenDistribution.objects.all() + + for token in tokens: + if ( + token.image + and token.image.name + and token.image.name.startswith("https://imagedelivery.net") + ): + # split the url to get the image id + token.image.name = token.image.name.split("/")[-2] + token.save() + + if ( + token.token_image + and token.token_image.name + and token.token_image.name.startswith("https://imagedelivery.net") + ): + token.token_image.name = token.token_image.name.split("/")[-2] + token.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("tokenTap", "0064_alter_constraint_name"), + ] + + operations = [ + migrations.RunPython( + fix_token_images_prefix, reverse_code=migrations.RunPython.noop + ) + ]