FIX: PM should never be allowed to have a category

FIX: TL3 should not be allowed to muck with PM titles
This commit is contained in:
Sam
2014-09-11 17:39:20 +10:00
parent f95611aba1
commit 0f585bcdbe
14 changed files with 47 additions and 19 deletions

View File

@ -0,0 +1,9 @@
class PrivateMessageShaveNoCategoryId < ActiveRecord::Migration
def up
execute "UPDATE topics SET category_id = NULL WHERE category_id IS NOT NULL AND archetype = \'private_message\'"
execute "ALTER TABLE topics ADD CONSTRAINT pm_has_no_category CHECK (category_id IS NULL OR archetype <> 'private_message')"
end
def down
raise ActiveRecord::IrreversibleMigration
end
end