2019-12-20 22:42:54 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-01-17 00:14:20 +08:00
|
|
|
require File.expand_path('app/helpers/database_helper')
|
|
|
|
|
2019-12-23 16:20:36 +08:00
|
|
|
class CreateRepositoryChecklists < ActiveRecord::Migration[6.0]
|
2020-01-17 00:14:20 +08:00
|
|
|
include DatabaseHelper
|
|
|
|
|
2020-01-16 22:30:19 +08:00
|
|
|
def up
|
2019-12-20 22:42:54 +08:00
|
|
|
create_table :repository_checklist_values do |t|
|
|
|
|
t.references :created_by, index: true, foreign_key: { to_table: :users }, null: true
|
|
|
|
t.references :last_modified_by, index: true, foreign_key: { to_table: :users }, null: true
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
|
|
|
create_table :repository_checklist_items do |t|
|
2020-01-16 22:30:19 +08:00
|
|
|
t.string :data, null: false
|
2019-12-20 22:42:54 +08:00
|
|
|
t.references :repository, null: false, foreign_key: true
|
|
|
|
t.references :repository_column, null: false, foreign_key: true
|
|
|
|
t.references :created_by, index: true, foreign_key: { to_table: :users }, null: true
|
|
|
|
t.references :last_modified_by, index: true, foreign_key: { to_table: :users }, null: true
|
|
|
|
|
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
|
2020-01-16 22:30:19 +08:00
|
|
|
add_gin_index_without_tags :repository_checklist_items, :data
|
|
|
|
|
2020-01-14 23:55:10 +08:00
|
|
|
create_table :repository_checklist_items_values do |t|
|
|
|
|
t.belongs_to :repository_checklist_value, index: { name: 'index_on_repository_checklist_value_id' }
|
|
|
|
t.belongs_to :repository_checklist_item, index: { name: 'index_on_repository_checklist_item_id' }
|
2019-12-20 22:42:54 +08:00
|
|
|
t.timestamps
|
|
|
|
end
|
|
|
|
end
|
2020-01-16 22:30:19 +08:00
|
|
|
|
|
|
|
def down
|
|
|
|
drop_table :repository_checklist_items_values
|
|
|
|
drop_table :repository_checklist_items
|
|
|
|
drop_table :repository_checklist_values
|
|
|
|
end
|
2019-12-20 22:42:54 +08:00
|
|
|
end
|