mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-04 12:51:41 -05:00
12 lines
343 B
Ruby
12 lines
343 B
Ruby
class AddSelfEditsToPosts < ActiveRecord::Migration
|
|
def up
|
|
add_column :posts, :self_edits, :integer, null: false, default: 0
|
|
execute "
|
|
UPDATE posts p SET self_edits = (SELECT COUNT(*) FROM post_revisions pr WHERE pr.post_id = p.id AND pr.user_id=p.user_id)
|
|
"
|
|
end
|
|
|
|
def down
|
|
remove_column :posts, :self_edits
|
|
end
|
|
end
|