tracks/db/migrate/008_add_subclass_attr_to_todos.rb

17 lines
422 B
Ruby
Raw Normal View History

2019-05-13 18:42:57 +02:00
class AddSubclassAttrToTodos < ActiveRecord::Migration[5.2]
class Todo < ActiveRecord::Base; end
class Immediate < Todo; end
def self.up
add_column :todos, :type, :string, :null => false, :default => "Immediate"
add_column :todos, :show_from, :date
2013-09-13 16:44:59 +02:00
Todo.all.each { |todo| todo.type = "Immediate" }
end
def self.down
remove_column :todos, :type
remove_column :todos, :show_from
end
end