Skip to content

Commit 074b580

Browse files
authored
fix: use old multitenancy in generated removals of previous indexes (#536)
1 parent 0124cb4 commit 074b580

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/migration_generator/operation.ex

+15-6
Original file line numberDiff line numberDiff line change
@@ -1219,29 +1219,38 @@ defmodule AshPostgres.MigrationGenerator.Operation do
12191219

12201220
defmodule RemoveCustomIndex do
12211221
@moduledoc false
1222-
defstruct [:schema, :table, :index, :base_filter, :multitenancy, no_phase: true]
1222+
defstruct [
1223+
:schema,
1224+
:table,
1225+
:index,
1226+
:base_filter,
1227+
:multitenancy,
1228+
:old_multitenancy,
1229+
no_phase: true
1230+
]
1231+
12231232
import Helper
12241233

12251234
def up(operation) do
1226-
AddCustomIndex.down(operation)
1235+
AddCustomIndex.down(%{operation | multitenancy: operation.old_multitenancy})
12271236
end
12281237

12291238
def down(operation) do
1230-
AddCustomIndex.up(operation)
1239+
AddCustomIndex.up(%{operation | multitenancy: operation.old_multitenancy})
12311240
end
12321241
end
12331242

12341243
defmodule RemoveReferenceIndex do
12351244
@moduledoc false
1236-
defstruct [:schema, :table, :source, :multitenancy, no_phase: true]
1245+
defstruct [:schema, :table, :source, :multitenancy, :old_multitenancy, no_phase: true]
12371246
import Helper
12381247

12391248
def up(operation) do
1240-
AddReferenceIndex.down(operation)
1249+
AddReferenceIndex.down(%{operation | multitenancy: operation.old_multitenancy})
12411250
end
12421251

12431252
def down(operation) do
1244-
AddReferenceIndex.up(operation)
1253+
AddReferenceIndex.up(%{operation | multitenancy: operation.old_multitenancy})
12451254
end
12461255
end
12471256

0 commit comments

Comments
 (0)