diff --git a/backend/prompt_studio/prompt_profile_manager/migrations/0005_removed_converter_and_added_x2text_foreign_key.py b/backend/prompt_studio/prompt_profile_manager/migrations/0005_removed_converter_and_added_x2text_foreign_key.py index 45def44f74..25f4b215bd 100644 --- a/backend/prompt_studio/prompt_profile_manager/migrations/0005_removed_converter_and_added_x2text_foreign_key.py +++ b/backend/prompt_studio/prompt_profile_manager/migrations/0005_removed_converter_and_added_x2text_foreign_key.py @@ -4,7 +4,7 @@ import django.db.models.deletion from cryptography.fernet import Fernet -from django.db import migrations, models +from django.db import connection, migrations, models def fill_with_default_x2text(apps, schema): @@ -35,6 +35,13 @@ def reversal_x2text(*args): """Reversal is NOOP since x2text is simply dropped during reverse.""" +def disable_triggers(apps, schema_editor): + with connection.cursor() as cursor: + cursor.execute( + "ALTER TABLE adapter_adapterinstance DISABLE TRIGGER ALL;" + ) + + class Migration(migrations.Migration): dependencies = [ ("account", "0005_encryptionsecret"), @@ -50,6 +57,9 @@ class Migration(migrations.Migration): model_name="profilemanager", name="pdf_to_text_converters", ), + migrations.RunPython( + disable_triggers, reverse_code=migrations.RunPython.noop + ), migrations.AddField( model_name="profilemanager", name="x2text", diff --git a/backend/prompt_studio/prompt_profile_manager/migrations/0006_alter_profilemanager_x2text.py b/backend/prompt_studio/prompt_profile_manager/migrations/0006_alter_profilemanager_x2text.py index e34d267962..cffa18dc50 100644 --- a/backend/prompt_studio/prompt_profile_manager/migrations/0006_alter_profilemanager_x2text.py +++ b/backend/prompt_studio/prompt_profile_manager/migrations/0006_alter_profilemanager_x2text.py @@ -1,7 +1,14 @@ # Generated by Django 4.2.1 on 2024-02-23 17:02 import django.db.models.deletion -from django.db import migrations, models +from django.db import connection, migrations, models + + +def enable_triggers(apps, schema_editor): + with connection.cursor() as cursor: + cursor.execute( + "ALTER TABLE adapter_adapterinstance ENABLE TRIGGER ALL;" + ) class Migration(migrations.Migration): @@ -24,4 +31,7 @@ class Migration(migrations.Migration): to="adapter_processor.adapterinstance", ), ), + migrations.RunPython( + enable_triggers, + ), ]