Update AuthorRole delete logic to cascade if no Book.
This commit is contained in:
+42
@@ -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
|
||||
Reference in New Issue
Block a user