@@ -0,0 +1,2439 @@
+# Generated by Django 2.0.13 on 2019-02-28 11:28%0A%0Aimport json%0A%0Afrom urllib.parse import unquote_plus%0A%0Afrom django.db import migrations%0A%0A%0Adef remove_signatures(apps, schema_editor):%0A    Recipe = apps.get_model(%22recipes%22, %22Recipe%22)%0A    Action = apps.get_model(%22recipes%22, %22Action%22)%0A    Signature = apps.get_model(%22recipes%22, %22Signature%22)%0A%0A    for recipe in Recipe.objects.exclude(signature=None):%0A        sig = recipe.signature%0A        recipe.signature = None%0A        recipe.save()%0A        sig.delete()%0A%0A    for action in Action.objects.exclude(signature=None):%0A        sig = action.signature%0A        action.signature = None%0A        action.save()%0A        sig.delete()%0A%0A    for sig in Signature.objects.all():%0A        sig.delete()%0A%0A%0Adef add_extension_id(apps, schema_editor):%0A    Action = apps.get_model(%22recipes%22, %22Action%22)%0A    RecipeRevision = apps.get_model(%22recipes%22, %22RecipeRevision%22)%0A    Extension = apps.get_model(%22studies%22, %22Extension%22)%0A%0A    action = Action.objects.get(name=%22opt-out-study%22)%0A    revisions = RecipeRevision.objects.filter(action_id=action.id)%0A%0A    for revision in revisions:%0A        arguments = json.loads(revision.arguments_json)%0A        url = arguments.get(%22addonUrl%22)%0A        filename = unquote_plus(url.split(%22/extensions/%22).pop())%0A        extension = Extension.objects.get(xpi=f%22extensions/%7Bfilename%7D%22)%0A        arguments%5B%22extensionApiId%22%5D = extension.id%0A        revision.arguments_json = json.dumps(arguments)%0A        revision.save()%0A%0A        # Remove signatures to prompt resigning%0A        remove_signatures(apps, schema_editor)%0A%0A%0Adef remove_extension_id(apps, schema_editor):%0A    Action = apps.get_model(%22recipes%22, %22Action%22)%0A    RecipeRevision = apps.get_model(%22recipes%22, %22RecipeRevision%22)%0A%0A    action = Action.objects.get(name=%22opt-out-study%22)%0A    revisions = RecipeRevision.objects.filter(action_id=action.id)%0A%0A    for revision in revisions:%0A        arguments = json.loads(revision.arguments_json)%0A        if %22extensionApiId%22 in arguments:%0A            arguments.pop(%22extensionApiId%22)%0A        revision.arguments_json = json.dumps(arguments)%0A        revision.save()%0A%0A        # Remove signatures to prompt resigning%0A        remove_signatures(apps, schema_editor)%0A%0A%0Aclass Migration(migrations.Migration):%0A%0A    dependencies = %5B%0A        (%22recipes%22, %220013_auto_20181018_2049%22),%0A        (%22studies%22, %220006_extension_hash_algorithm%22),%0A    %5D%0A%0A    operations = %5Bmigrations.RunPython(add_extension_id, remove_extension_id)%5D%0A

Add migration to add extension ID to addon study recipes