mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-15 14:48:40 +00:00
26 lines
848 B
Ruby
26 lines
848 B
Ruby
# frozen_string_literal: true
|
|
|
|
class MigrateSettings < ActiveRecord::Migration[4.2]
|
|
def up
|
|
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
|
|
end
|
|
|
|
def down
|
|
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
|
|
t.column :target_id, :integer, null: false
|
|
t.column :target_type, :string, null: false, default: ''
|
|
t.index [:target_type, :target_id, :var], unique: true
|
|
end
|
|
end
|
|
end
|