chore(schema): migrate flipper value string to text

This commit is contained in:
Colin Darie 2024-02-05 10:43:54 +01:00
parent 57b398adf3
commit aa7d3a7656
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
2 changed files with 21 additions and 1 deletions

View file

@ -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

View file

@ -614,7 +614,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_02_15_164247) do
t.string "feature_key", null: false t.string "feature_key", null: false
t.string "key", null: false t.string "key", null: false
t.datetime "updated_at", precision: nil, 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 t.index ["feature_key", "key", "value"], name: "index_flipper_gates_on_feature_key_and_key_and_value", unique: true
end end