From 54a169463749bda04777cb6ac15d77f0f0d6760a Mon Sep 17 00:00:00 2001 From: Roman Rizzi Date: Mon, 20 Mar 2023 12:55:38 -0300 Subject: [PATCH] FIX: Remove old seeded prompts. (#17) We switched to negative integers for seeded prompts, but we also need to delete the old ones using IDs 1/2/3 if they exist, or deploys will fail due to the unique index on the name column. --- ...0122645_delete_duplicated_seeded_prompts.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/migrate/20230320122645_delete_duplicated_seeded_prompts.rb diff --git a/db/migrate/20230320122645_delete_duplicated_seeded_prompts.rb b/db/migrate/20230320122645_delete_duplicated_seeded_prompts.rb new file mode 100644 index 00000000..81d06821 --- /dev/null +++ b/db/migrate/20230320122645_delete_duplicated_seeded_prompts.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DeleteDuplicatedSeededPrompts < ActiveRecord::Migration[7.0] + def up + DB.exec <<~SQL + DELETE FROM completion_prompts + WHERE ( + (id = 1 AND name = 'translate') OR + (id = 2 AND name = 'generate_titles') OR + (id = 3 AND name = 'proofread') + ) + SQL + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end