mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 15:50:13 +01:00
21 lines
693 B
Ruby
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
|