From 3e50a0d1197f8cfb95e1a6f8eaab096671c86b72 Mon Sep 17 00:00:00 2001 From: Zach Daniel Date: Sun, 6 Jun 2021 03:31:22 -0400 Subject: [PATCH] fix: generate multitenant foreign keys properly --- lib/migration_generator/operation.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/migration_generator/operation.ex b/lib/migration_generator/operation.ex index 5f0233f..7b46803 100644 --- a/lib/migration_generator/operation.ex +++ b/lib/migration_generator/operation.ex @@ -147,6 +147,7 @@ defmodule AshPostgres.MigrationGenerator.Operation do %{ references: %{ + multitenancy: %{strategy: :context}, table: table, destination_field: destination_field } = reference @@ -159,7 +160,7 @@ defmodule AshPostgres.MigrationGenerator.Operation do "column: #{inspect(destination_field)}", "name: #{inspect(reference.name)}", "type: #{inspect(reference_type(attribute, reference))}", - "prefix: \"public\"", + "prefix: prefix()", on_delete(reference), on_update(reference) ], @@ -176,7 +177,6 @@ defmodule AshPostgres.MigrationGenerator.Operation do %{ references: %{ - multitenancy: %{strategy: :context}, table: table, destination_field: destination_field } = reference @@ -189,6 +189,7 @@ defmodule AshPostgres.MigrationGenerator.Operation do "column: #{inspect(destination_field)}", "name: #{inspect(reference.name)}", "type: #{inspect(reference_type(attribute, reference))}", + "prefix: \"public\"", on_delete(reference), on_update(reference) ], @@ -330,6 +331,7 @@ defmodule AshPostgres.MigrationGenerator.Operation do "references(:#{table}, column: #{inspect(destination_field)}", "name: #{inspect(reference.name)}", "type: #{inspect(reference_type(attribute, reference))}", + "prefix: prefix()", on_delete(reference), on_update(reference), ")"