Add BookId as ids for Book.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
defmodule DecentralisedBookIndex.Repo.Migrations.AddBookIdsAndBookRelationship 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
|
||||
alter table(:books) do
|
||||
remove :isbn
|
||||
end
|
||||
|
||||
create table(:book_ids, primary_key: false) do
|
||||
add :id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true
|
||||
add :type, :text, null: false
|
||||
add :bid, :text, null: false
|
||||
add :order, :bigint, null: false
|
||||
|
||||
add :inserted_at, :utc_datetime_usec,
|
||||
null: false,
|
||||
default: fragment("(now() AT TIME ZONE 'utc')")
|
||||
|
||||
add :updated_at, :utc_datetime_usec,
|
||||
null: false,
|
||||
default: fragment("(now() AT TIME ZONE 'utc')")
|
||||
|
||||
add :book_id,
|
||||
references(:books,
|
||||
column: :id,
|
||||
name: "book_ids_book_id_fkey",
|
||||
type: :uuid,
|
||||
prefix: "public"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
drop constraint(:book_ids, "book_ids_book_id_fkey")
|
||||
|
||||
drop table(:book_ids)
|
||||
|
||||
alter table(:books) do
|
||||
add :isbn, :text, null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user