cirandas.net

ref: master

db/migrate/20120402205653_remove_broken_references_to_category.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class RemoveBrokenReferencesToCategory < ActiveRecord::Migration
  def self.up
    execute <<-SQL
      delete from articles_categories where category_id not in (select id from categories);
    SQL
    execute <<-SQL
      delete from categories_profiles where category_id not in (select id from categories);
    SQL
  end

  def self.down
    say "this migration can't be reverted"
  end
end