DEV: Replace old field_type text column with field_type_enum integer column (#27448)

Follow up to: #27444. In that PR we added a new integer column for UserField#field_type and populated the data based on the old text field.

In this PR we drop the old text column and swap in the new integer (enum) column.
This commit is contained in:
Ted Johansson
2024-06-12 16:41:02 +08:00
committed by GitHub
parent 7e31a8104d
commit 6be4ef59fa
2 changed files with 16 additions and 6 deletions

View File

@ -0,0 +1,14 @@
# frozen_string_literal: true
class SwapFieldTypeWithFieldTypeEnumOnUserFields < ActiveRecord::Migration[7.0]
DROPPED_COLUMNS ||= { user_fields: %i[field_type] }
def up
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
rename_column :user_fields, :field_type_enum, :field_type
end
def down
raise ActiveRecord::IrreversibleMigration
end
end