2023-07-12 09:47:08 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-05 02:43:02 +02:00
|
|
|
class MigrateSettings < ActiveRecord::Migration[4.2]
|
2017-01-12 20:46:24 +01:00
|
|
|
def up
|
2023-11-06 17:15:48 +01:00
|
|
|
change_table(:settings, bulk: true) do |t|
|
|
|
|
t.remove_index [:target_type, :target_id, :var]
|
|
|
|
t.rename :target_id, :thing_id
|
|
|
|
t.rename :target_type, :thing_type
|
|
|
|
t.change :thing_id, :integer, null: true, default: nil
|
|
|
|
t.change :thing_type, :string, null: true, default: nil
|
|
|
|
t.index [:thing_type, :thing_id, :var], unique: true
|
|
|
|
end
|
2017-01-12 20:46:24 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2023-11-06 17:15:48 +01:00
|
|
|
change_table(:settings, bulk: true) do |t|
|
|
|
|
t.remove_index [:thing_type, :thing_id, :var]
|
|
|
|
t.rename :thing_id, :target_id
|
|
|
|
t.rename :thing_type, :target_type
|
2024-12-16 14:50:58 +01:00
|
|
|
t.column :target_id, :integer, null: false # rubocop:disable Rails/NotNullColumn
|
2023-11-06 17:15:48 +01:00
|
|
|
t.column :target_type, :string, null: false, default: ''
|
|
|
|
t.index [:target_type, :target_id, :var], unique: true
|
|
|
|
end
|
2017-01-12 20:46:24 +01:00
|
|
|
end
|
|
|
|
end
|