2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-31 12:06:56 +08:00
|
|
|
class CreateTopicRevisions < ActiveRecord::Migration[4.2]
|
2013-12-12 10:41:34 +08:00
|
|
|
def up
|
|
|
|
create_table :topic_revisions do |t|
|
|
|
|
t.belongs_to :user
|
|
|
|
t.belongs_to :topic
|
|
|
|
t.text :modifications
|
|
|
|
t.integer :number
|
2017-08-07 23:48:36 +08:00
|
|
|
t.timestamps null: false
|
2013-12-12 10:41:34 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
execute "INSERT INTO topic_revisions (user_id, topic_id, modifications, number, created_at, updated_at)
|
|
|
|
SELECT user_id, versioned_id, modifications, number, created_at, updated_at
|
|
|
|
FROM versions
|
|
|
|
WHERE versioned_type = 'Topic'"
|
|
|
|
|
|
|
|
change_table :topic_revisions do |t|
|
|
|
|
t.index :topic_id
|
|
|
|
t.index [:topic_id, :number]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
drop_table :topic_revisions
|
|
|
|
end
|
|
|
|
end
|