2019-05-13 18:42:57 +02:00
|
|
|
class AddUserId < ActiveRecord::Migration[5.2]
|
2021-01-06 15:33:13 +02:00
|
|
|
|
2007-03-30 04:36:52 +00:00
|
|
|
class Project < ActiveRecord::Base; end
|
|
|
|
|
class Context < ActiveRecord::Base; end
|
|
|
|
|
class Todo < ActiveRecord::Base; end
|
2021-01-06 15:33:13 +02:00
|
|
|
|
2007-03-30 04:36:52 +00:00
|
|
|
def self.up
|
|
|
|
|
add_column :contexts, :user_id, :integer, :default => 1
|
2021-01-06 15:33:13 +02:00
|
|
|
add_column :projects, :user_id, :integer, :default => 1
|
2007-03-30 04:36:52 +00:00
|
|
|
add_column :todos, :user_id, :integer, :default => 1
|
2013-09-13 16:44:59 +02:00
|
|
|
Context.all.each { |context| context.user_id = 1 }
|
|
|
|
|
Project.all.each { |project| project.user_id = 1 }
|
|
|
|
|
Todo.all.each { |todo| todo.user_id = 1 }
|
2007-03-30 04:36:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
|
remove_column :contexts, :user_id
|
|
|
|
|
remove_column :projects, :user_id
|
|
|
|
|
remove_column :todos, :user_id
|
|
|
|
|
end
|
|
|
|
|
end
|