Update AuthorRole delete logic to cascade if no Book.

This commit is contained in:
2025-04-08 17:28:45 +03:00
parent d1a44a5457
commit 74570c81a1
3 changed files with 202 additions and 0 deletions
@@ -0,0 +1,42 @@
defmodule DecentralisedBookIndex.Repo.Migrations.UpdateAuthorRoleDeleteLogicToCascadeIfNoBook do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""
use Ecto.Migration
def up do
drop constraint(:author_role, "author_role_book_id_fkey")
alter table(:author_role) do
modify :book_id,
references(:books,
column: :id,
name: "author_role_book_id_fkey",
type: :uuid,
prefix: "public",
on_delete: :delete_all
)
end
create index(:author_role, [:book_id])
end
def down do
drop_if_exists index(:author_role, [:book_id])
drop constraint(:author_role, "author_role_book_id_fkey")
alter table(:author_role) do
modify :book_id,
references(:books,
column: :id,
name: "author_role_book_id_fkey",
type: :uuid,
prefix: "public"
)
end
end
end