dceed1caa1
Merge remote-tracking branch 'origin/main' into feature/046 #46 #46 #46 #46 #46 #46 Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #339
25 lines
946 B
Ruby
25 lines
946 B
Ruby
class CreatePostImplications < ActiveRecord::Migration[8.0]
|
|
def up
|
|
create_table :post_implications, primary_key: [:post_id, :parent_post_id] do |t|
|
|
t.references :post, null: false, foreign_key: true, index: false
|
|
t.references :parent_post, null: false, foreign_key: { to_table: :posts }
|
|
t.timestamps
|
|
|
|
t.check_constraint 'post_id <> parent_post_id',
|
|
name: 'chk_post_implications_no_self'
|
|
end
|
|
|
|
add_column :post_versions, :parent_post_ids, :text, null: false, after: :parent_id
|
|
remove_column :post_versions, :parent_id, :bigint
|
|
remove_reference :posts, :parent, foreign_key: { to_table: :posts }
|
|
end
|
|
|
|
def down
|
|
add_reference :posts, :parent, foreign_key: { to_table: :posts }, after: :thumbnail_base
|
|
add_column :post_versions, :parent_id, :bigint, after: :post_id
|
|
remove_column :post_versions, :parent_post_ids, :text
|
|
|
|
drop_table :post_implications
|
|
end
|
|
end
|