initial book review schema

This commit is contained in:
Daniel Yrovas 2025-01-09 21:43:05 +11:00
parent e218290e08
commit 90414e6b93
Signed by: danielyrovas
SSH key fingerprint: SHA256:1avlGZQpGW038lBkNI5lOS7f0hIPM7ecJen2/P1MCCU
15 changed files with 653 additions and 0 deletions

View file

@ -0,0 +1,15 @@
defmodule Wild.Repo.Migrations.CreateAuthors do
use Ecto.Migration
def change do
create table(:authors) do
add :name, :string
add :country, :string
add :bio, :string
add :year_born, :string
add :year_died, :string
timestamps(type: :utc_datetime)
end
end
end

View file

@ -0,0 +1,16 @@
defmodule Wild.Repo.Migrations.CreateBooks do
use Ecto.Migration
def change do
create table(:books) do
add :title, :string
add :blurb, :string
add :publication_year, :string
add :author_id, references(:authors, on_delete: :nothing)
timestamps(type: :utc_datetime)
end
create index(:books, [:author_id])
end
end

View file

@ -0,0 +1,20 @@
defmodule Wild.Repo.Migrations.CreateBookReads do
use Ecto.Migration
def change do
create table(:book_reads) do
add :rating, :integer
add :thoughts, :string
add :read_start, :utc_datetime
add :read_finish, :utc_datetime
add :progress, :integer
add :user_id, references(:users, on_delete: :nothing)
add :book_id, references(:books, on_delete: :nothing)
timestamps(type: :utc_datetime)
end
create index(:book_reads, [:user_id])
create index(:book_reads, [:book_id])
end
end