From aa7d3a7656dcf5cadfd63bdd6d438a5db31af024 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Mon, 5 Feb 2024 10:43:54 +0100 Subject: [PATCH] chore(schema): migrate flipper value string to text --- ...3954_change_flipper_gates_value_to_text.rb | 20 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20240205093954_change_flipper_gates_value_to_text.rb diff --git a/db/migrate/20240205093954_change_flipper_gates_value_to_text.rb b/db/migrate/20240205093954_change_flipper_gates_value_to_text.rb new file mode 100644 index 000000000..937b69fb6 --- /dev/null +++ b/db/migrate/20240205093954_change_flipper_gates_value_to_text.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class ChangeFlipperGatesValueToText < ActiveRecord::Migration[7.0] + disable_ddl_transaction! + + def up + # Ensure this incremental update migration is idempotent + return unless connection.column_exists? :flipper_gates, :value, :string + + if index_exists? :flipper_gates, [:feature_key, :key, :value] + remove_index :flipper_gates, [:feature_key, :key, :value] + end + change_column :flipper_gates, :value, :text + add_index :flipper_gates, [:feature_key, :key, :value], unique: true, length: { value: 255 }, algorithm: :concurrently + end + + def down + change_column :flipper_gates, :value, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index ad3dbb338..2f9235b5d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -614,7 +614,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_02_15_164247) do t.string "feature_key", null: false t.string "key", null: false t.datetime "updated_at", precision: nil, null: false - t.string "value" + t.text "value" t.index ["feature_key", "key", "value"], name: "index_flipper_gates_on_feature_key_and_key_and_value", unique: true end