Reputation: 3506
So currently my table has a date
, and a date index, I want to drop the date index, add a start_date
and end_date
, and initially set both the start and end date equal to whatever date
was, and then add start and end date indexes. Can this all be done in one migration? How would that look?
Upvotes: 0
Views: 57
Reputation: 9831
def up do
alter table(:table) do
add :start_date, :date
add :end_date, :date
end
execute "update table set start_date=date, end_date=date"
alter table(:table) do
remove :date
end
create index(:table, :start_date)
create index(:table, :end_date)
end
Index will for date
will be removed with field removal.
Upvotes: 1