tracks/db/migrate/002_add_user_id.rb
2008-05-20 21:28:26 +01:00

21 lines
693 B
Ruby

class AddUserId < ActiveRecord::Migration
class Project < ActiveRecord::Base; end
class Context < ActiveRecord::Base; end
class Todo < ActiveRecord::Base; end
def self.up
add_column :contexts, :user_id, :integer, :default => 1
add_column :projects, :user_id, :integer, :default => 1
add_column :todos, :user_id, :integer, :default => 1
Context.find(:all).each { |context| context.user_id = 1 }
Project.find(:all).each { |project| project.user_id = 1 }
Todo.find(:all).each { |todo| todo.user_id = 1 }
end
def self.down
remove_column :contexts, :user_id
remove_column :projects, :user_id
remove_column :todos, :user_id
end
end