Update BookId to add the reference logic.

This commit is contained in:
2025-03-20 16:49:17 +02:00
parent ddd300625c
commit 709905a8e1
3 changed files with 160 additions and 1 deletions
@@ -0,0 +1,42 @@
defmodule DecentralisedBookIndex.Repo.Migrations.UpdateBookIdToAddReferenceLogic 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(:book_ids, "book_ids_book_id_fkey")
alter table(:book_ids) do
modify :book_id,
references(:books,
column: :id,
name: "book_ids_book_id_fkey",
type: :uuid,
prefix: "public",
on_delete: :delete_all
)
end
create index(:book_ids, [:book_id])
end
def down do
drop_if_exists index(:book_ids, [:book_id])
drop constraint(:book_ids, "book_ids_book_id_fkey")
alter table(:book_ids) do
modify :book_id,
references(:books,
column: :id,
name: "book_ids_book_id_fkey",
type: :uuid,
prefix: "public"
)
end
end
end