2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 00:06:56 -04:00
|
|
|
class CreatePostRevisions < ActiveRecord::Migration[4.2]
|
2013-12-11 21:41:34 -05:00
|
|
|
def up
|
|
|
|
create_table :post_revisions do |t|
|
|
|
|
t.belongs_to :user
|
|
|
|
t.belongs_to :post
|
|
|
|
t.text :modifications
|
|
|
|
t.integer :number
|
2017-08-07 11:48:36 -04:00
|
|
|
t.timestamps null: false
|
2013-12-11 21:41:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
execute "INSERT INTO post_revisions (user_id, post_id, modifications, number, created_at, updated_at)
|
|
|
|
SELECT user_id, versioned_id, modifications, number, created_at, updated_at
|
|
|
|
FROM versions
|
|
|
|
WHERE versioned_type = 'Post'"
|
|
|
|
|
|
|
|
change_table :post_revisions do |t|
|
|
|
|
t.index :post_id
|
|
|
|
t.index [:post_id, :number]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
drop_table :post_revisions
|
|
|
|
end
|
|
|
|
end
|