mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
fix: fix migrator mix tasks w/ only/except tenants
fix: drop foreign keys after table create properly
This commit is contained in:
parent
7f5a56d9bd
commit
ddbd43b611
3 changed files with 13 additions and 9 deletions
|
@ -247,6 +247,9 @@ defmodule AshPostgres.MigrationGenerator do
|
|||
|
||||
defp comment_out_phases(phases) do
|
||||
Enum.map(phases, fn
|
||||
%{operations: []} = phase ->
|
||||
phase
|
||||
|
||||
%{operations: operations} = phase ->
|
||||
if Enum.all?(operations, &match?(%{commented?: true}, &1)) do
|
||||
%{phase | commented?: true}
|
||||
|
@ -961,15 +964,6 @@ defmodule AshPostgres.MigrationGenerator do
|
|||
),
|
||||
do: true
|
||||
|
||||
defp after?(
|
||||
%Operation.CreateTable{table: table},
|
||||
%Operation.DropForeignKey{
|
||||
table: table,
|
||||
direction: :down
|
||||
}
|
||||
),
|
||||
do: true
|
||||
|
||||
defp after?(%Operation.AddAttribute{table: table}, %Operation.CreateTable{table: table}) do
|
||||
true
|
||||
end
|
||||
|
@ -1235,6 +1229,12 @@ defmodule AshPostgres.MigrationGenerator do
|
|||
old_attribute: Map.delete(attribute, :references),
|
||||
new_attribute: attribute,
|
||||
table: snapshot.table
|
||||
},
|
||||
%Operation.DropForeignKey{
|
||||
attribute: attribute,
|
||||
table: snapshot.table,
|
||||
multitenancy: Map.get(attribute, :multitenancy),
|
||||
direction: :down
|
||||
}
|
||||
]
|
||||
else
|
||||
|
|
|
@ -119,6 +119,8 @@ defmodule Mix.Tasks.AshPostgres.Migrate do
|
|||
|> AshPostgres.MixHelpers.delete_arg("--apis")
|
||||
|> AshPostgres.MixHelpers.delete_arg("--migrations-path")
|
||||
|> AshPostgres.MixHelpers.delete_flag("--tenants")
|
||||
|> AshPostgres.MixHelpers.delete_flag("--only-tenants")
|
||||
|> AshPostgres.MixHelpers.delete_flag("--except-tenants")
|
||||
|
||||
if opts[:tenants] do
|
||||
for repo <- repos do
|
||||
|
|
|
@ -78,6 +78,8 @@ defmodule Mix.Tasks.AshPostgres.Rollback do
|
|||
|> AshPostgres.MixHelpers.delete_arg("--apis")
|
||||
|> AshPostgres.MixHelpers.delete_arg("--migrations-path")
|
||||
|> AshPostgres.MixHelpers.delete_flag("--tenants")
|
||||
|> AshPostgres.MixHelpers.delete_flag("--only-tenants")
|
||||
|> AshPostgres.MixHelpers.delete_flag("--except-tenants")
|
||||
|
||||
if opts[:tenants] do
|
||||
for repo <- repos do
|
||||
|
|
Loading…
Reference in a new issue