summaryrefslogtreecommitdiffstats
path: root/db/migrate/20130710182539_add_queries_visibility.rb
blob: d6cd1a7b3176d18c3f1aca331e0237a94b7a82e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
class AddQueriesVisibility < ActiveRecord::Migration
  def up
    add_column :queries, :visibility, :integer, :default => 0
    Query.where(:is_public => true).update_all(:visibility => 2)
    remove_column :queries, :is_public
  end

  def down
    add_column :queries, :is_public, :boolean, :default => true, :null => false
    Query.where('visibility <> ?', 2).update_all(:is_public => false)
    remove_column :queries, :visibility
  end
end