Update BookId to add the reference logic.
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user