Skip to content

Commit

Permalink
fix: deployment migration (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
pichoemr authored Feb 22, 2023
1 parent f716872 commit 55c35a2
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ defmodule :"Elixir.Lenra.Repo.Migrations.Deployment-change" do
add(:deployment_id, references(:deployments))
end

execute("UPDATE environments SET deployment_id =
(SELECT d.id FROM environments AS e
JOIN deployments AS d ON d.build_id = e.deployed_build_id)")
execute("UPDATE environments AS e SET deployment_id =
(SELECT d.id FROM deployments AS d WHERE d.build_id = e.deployed_build_id)")

alter table(:environments) do
remove(:deployed_build_id, references(:builds))
Expand All @@ -34,10 +33,9 @@ defmodule :"Elixir.Lenra.Repo.Migrations.Deployment-change" do
add(:deployed_build_id, references(:builds))
end

execute("UPDATE environments SET deployed_build_id = (
SELECT b.id FROM environments AS e
JOIN deployments AS d ON d.id = e.deployment_id
JOIN builds as b ON d.build_id = b.id)")
execute("UPDATE environments AS e SET deployed_build_id = (
SELECT b.id FROM builds as b
JOIN deployments AS d ON d.id = e.deployment_id)")

alter table(:environments) do
remove(:deployment_id, references(:deployments))
Expand Down

0 comments on commit 55c35a2

Please sign in to comment.