Executes queue migration commands immediately

This commit is contained in:
Adrian Kumpf
2020-02-23 12:23:57 +01:00
parent 1e4a6131e2
commit 2aa14c62be
@@ -4,12 +4,16 @@ defmodule TeslaMate.Repo.Migrations.CascadeDelete do
def up do
drop(constraint(:cars, "cars_settings_id_fkey"))
flush()
alter table(:cars) do
modify(:settings_id, references(:car_settings, on_delete: :delete_all), null: false)
end
drop(constraint(:charges, "charges_charging_process_id_fkey"))
flush()
alter table(:charges) do
modify(:charging_process_id, references(:charging_processes, on_delete: :delete_all),
null: false
@@ -20,6 +24,8 @@ defmodule TeslaMate.Repo.Migrations.CascadeDelete do
drop(constraint(:charging_processes, "charging_processes_address_id_fkey"))
drop(constraint(:charging_processes, "charging_processes_geofence_id_fkey"))
flush()
alter table(:charging_processes) do
modify(:car_id, references(:cars, on_delete: :delete_all), null: false)
modify(:address_id, references(:addresses, on_delete: :nilify_all))
@@ -40,6 +46,8 @@ defmodule TeslaMate.Repo.Migrations.CascadeDelete do
drop(constraint(:drives, "drives_start_geofence_id_fkey"))
drop(constraint(:drives, "drives_end_geofence_id_fkey"))
flush()
alter table(:drives) do
modify(:car_id, references(:cars, on_delete: :delete_all), null: false)
@@ -56,6 +64,8 @@ defmodule TeslaMate.Repo.Migrations.CascadeDelete do
drop(constraint(:positions, "positions_car_id_fkey"))
drop(constraint(:positions, "positions_drive_id_fkey"))
flush()
alter table(:positions) do
modify(:car_id, references(:cars, on_delete: :delete_all), null: false)
modify(:drive_id, references(:drives, on_delete: :nilify_all))
@@ -63,12 +73,16 @@ defmodule TeslaMate.Repo.Migrations.CascadeDelete do
drop(constraint(:states, "states_car_id_fkey"))
flush()
alter table(:states) do
modify(:car_id, references(:cars, on_delete: :delete_all), null: false)
end
drop(constraint(:updates, "updates_car_id_fkey"))
flush()
alter table(:updates) do
modify(:car_id, references(:cars, on_delete: :delete_all), null: false)
end