ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
946 B

  1. class CreatePostImplications < ActiveRecord::Migration[8.0]
  2. def up
  3. create_table :post_implications, primary_key: [:post_id, :parent_post_id] do |t|
  4. t.references :post, null: false, foreign_key: true, index: false
  5. t.references :parent_post, null: false, foreign_key: { to_table: :posts }
  6. t.timestamps
  7. t.check_constraint 'post_id <> parent_post_id',
  8. name: 'chk_post_implications_no_self'
  9. end
  10. add_column :post_versions, :parent_post_ids, :text, null: false, after: :parent_id
  11. remove_column :post_versions, :parent_id, :bigint
  12. remove_reference :posts, :parent, foreign_key: { to_table: :posts }
  13. end
  14. def down
  15. add_reference :posts, :parent, foreign_key: { to_table: :posts }, after: :thumbnail_base
  16. add_column :post_versions, :parent_id, :bigint, after: :post_id
  17. remove_column :post_versions, :parent_post_ids, :text
  18. drop_table :post_implications
  19. end
  20. end