2020-04-07 23:59:46 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AddRepositorySnapshots < ActiveRecord::Migration[6.0]
|
2020-04-09 18:33:04 +08:00
|
|
|
def up
|
2020-04-29 16:42:00 +08:00
|
|
|
change_table :repositories, bulk: true do |t|
|
|
|
|
t.string :type
|
|
|
|
t.bigint :parent_id, null: true
|
|
|
|
t.integer :status, null: true
|
2020-05-12 22:26:44 +08:00
|
|
|
t.boolean :selected, null: true
|
|
|
|
t.references :my_module
|
2020-04-29 16:42:00 +08:00
|
|
|
end
|
|
|
|
|
2020-04-09 18:33:04 +08:00
|
|
|
execute "UPDATE \"repositories\" SET \"type\" = 'Repository'"
|
|
|
|
execute "UPDATE \"activities\" SET \"subject_type\" = 'RepositoryBase' WHERE \"subject_type\" = 'Repository'"
|
|
|
|
|
|
|
|
add_column :repository_columns, :parent_id, :bigint, null: true
|
2020-04-07 23:59:46 +08:00
|
|
|
add_column :repository_rows, :parent_id, :bigint, null: true
|
2020-04-09 18:33:04 +08:00
|
|
|
|
|
|
|
remove_reference :repository_list_items, :repository, index: true, foreign_key: true
|
|
|
|
remove_reference :repository_status_items, :repository, foreign_key: true
|
|
|
|
remove_reference :repository_checklist_items, :repository, foreign_key: true
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
add_reference :repository_list_items, :repository, index: true, foreign_key: true
|
|
|
|
add_reference :repository_status_items, :repository, index: true, foreign_key: true
|
|
|
|
add_reference :repository_checklist_items, :repository, index: true, foreign_key: true
|
|
|
|
|
|
|
|
remove_column :repository_columns, :parent_id
|
|
|
|
remove_column :repository_rows, :parent_id
|
|
|
|
|
|
|
|
execute "UPDATE \"activities\" SET \"subject_type\" = 'Repository' WHERE \"subject_type\" = 'RepositoryBase'"
|
|
|
|
|
2020-05-12 22:26:44 +08:00
|
|
|
change_table :repositories, bulk: true do |t|
|
|
|
|
t.remove :type
|
|
|
|
t.remove :parent_id
|
|
|
|
t.remove :status
|
|
|
|
t.remove :selected
|
|
|
|
t.remove_references :my_module
|
|
|
|
end
|
2020-04-07 23:59:46 +08:00
|
|
|
end
|
|
|
|
end
|