2018-10-11 17:37:39 +02:00
|
|
|
defmodule Mobilizon.Repo.Migrations.AddAddressType do
|
2018-07-04 14:29:17 +02:00
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
def up do
|
|
|
|
alter table(:events) do
|
2019-02-22 14:18:52 +01:00
|
|
|
add(:online_address, :string)
|
|
|
|
add(:phone, :string)
|
2018-07-04 14:29:17 +02:00
|
|
|
end
|
2019-02-22 14:18:52 +01:00
|
|
|
|
|
|
|
drop(constraint(:events, "events_address_id_fkey"))
|
|
|
|
rename(table(:events), :address_id, to: :physical_address_id)
|
|
|
|
|
2018-07-04 14:29:17 +02:00
|
|
|
alter table(:events) do
|
2019-02-22 14:18:52 +01:00
|
|
|
modify(:physical_address_id, references(:addresses, on_delete: :nothing))
|
2018-07-04 14:29:17 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
|
|
|
alter table(:events) do
|
2019-02-22 14:18:52 +01:00
|
|
|
remove(:online_address)
|
|
|
|
remove(:phone)
|
2018-07-04 14:29:17 +02:00
|
|
|
end
|
2019-02-22 14:18:52 +01:00
|
|
|
|
|
|
|
drop(constraint(:events, "events_physical_address_id_fkey"))
|
|
|
|
rename(table(:events), :physical_address_id, to: :address_id)
|
|
|
|
|
2018-07-04 14:29:17 +02:00
|
|
|
alter table(:events) do
|
2019-02-22 14:18:52 +01:00
|
|
|
modify(:address_id, references(:addresses, on_delete: :nothing))
|
2018-07-04 14:29:17 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|