discourse/db/migrate/20131209091702_create_post_revisions.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

28 lines
713 B
Ruby

# frozen_string_literal: true
class CreatePostRevisions < ActiveRecord::Migration[4.2]
def up
create_table :post_revisions do |t|
t.belongs_to :user
t.belongs_to :post
t.text :modifications
t.integer :number
t.timestamps null: false
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