Add the Publisher resource.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
defmodule DecentralisedBookIndex.Repo.Migrations.AddPublisherAndUpdateBookRelationship 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
|
||||
create table(:publishers, primary_key: false) do
|
||||
add :id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true
|
||||
add :name, :text, 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')")
|
||||
end
|
||||
|
||||
alter table(:books) do
|
||||
add :publisher_id,
|
||||
references(:publishers,
|
||||
column: :id,
|
||||
name: "books_publisher_id_fkey",
|
||||
type: :uuid,
|
||||
prefix: "public"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
drop constraint(:books, "books_publisher_id_fkey")
|
||||
|
||||
alter table(:books) do
|
||||
remove :publisher_id
|
||||
end
|
||||
|
||||
drop table(:publishers)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user