From 8bab3abd0ade21dd8d7d099a711b98f6de2f69cb Mon Sep 17 00:00:00 2001 From: Dmitry Maganov Date: Wed, 23 Apr 2025 17:54:11 +0300 Subject: [PATCH] fix: use old multitenancy in generated removals of previous indexes --- lib/migration_generator/operation.ex | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/migration_generator/operation.ex b/lib/migration_generator/operation.ex index 14f7b52b..475b88e5 100644 --- a/lib/migration_generator/operation.ex +++ b/lib/migration_generator/operation.ex @@ -1219,29 +1219,38 @@ defmodule AshPostgres.MigrationGenerator.Operation do defmodule RemoveCustomIndex do @moduledoc false - defstruct [:schema, :table, :index, :base_filter, :multitenancy, no_phase: true] + defstruct [ + :schema, + :table, + :index, + :base_filter, + :multitenancy, + :old_multitenancy, + no_phase: true + ] + import Helper def up(operation) do - AddCustomIndex.down(operation) + AddCustomIndex.down(%{operation | multitenancy: operation.old_multitenancy}) end def down(operation) do - AddCustomIndex.up(operation) + AddCustomIndex.up(%{operation | multitenancy: operation.old_multitenancy}) end end defmodule RemoveReferenceIndex do @moduledoc false - defstruct [:schema, :table, :source, :multitenancy, no_phase: true] + defstruct [:schema, :table, :source, :multitenancy, :old_multitenancy, no_phase: true] import Helper def up(operation) do - AddReferenceIndex.down(operation) + AddReferenceIndex.down(%{operation | multitenancy: operation.old_multitenancy}) end def down(operation) do - AddReferenceIndex.up(operation) + AddReferenceIndex.up(%{operation | multitenancy: operation.old_multitenancy}) end end