diff --git a/lib/wild/accounts/user.ex b/lib/wild/accounts/user.ex
index 1e68758..d3c1346 100644
--- a/lib/wild/accounts/user.ex
+++ b/lib/wild/accounts/user.ex
@@ -9,6 +9,8 @@ defmodule Wild.Accounts.User do
field :current_password, :string, virtual: true, redact: true
field :confirmed_at, :utc_datetime
+ has_many :book_reads, Wild.BookReads.BookRead
+
timestamps(type: :utc_datetime)
end
diff --git a/lib/wild/book_reads/book_read.ex b/lib/wild/book_reads/book_read.ex
index 6fe07f8..9624797 100644
--- a/lib/wild/book_reads/book_read.ex
+++ b/lib/wild/book_reads/book_read.ex
@@ -9,8 +9,9 @@ defmodule Wild.BookReads.BookRead do
field :thoughts, :string
field :read_start, :utc_datetime
field :read_finish, :utc_datetime
- field :user_id, :id, primary_key: true
- field :book_id, :id, primary_key: true
+
+ belongs_to :user, Wild.Accounts.User, type: :id, primary_key: true
+ belongs_to :book, Wild.Books.Book, type: :id, primary_key: true
timestamps(type: :utc_datetime)
end
diff --git a/lib/wild/books/author.ex b/lib/wild/books/author.ex
index f327f85..a1c1391 100644
--- a/lib/wild/books/author.ex
+++ b/lib/wild/books/author.ex
@@ -9,6 +9,8 @@ defmodule Wild.Books.Author do
field :year_born, :string
field :year_died, :string
+ has_many :books, Wild.Books.Book
+
timestamps(type: :utc_datetime)
end
diff --git a/lib/wild/books/book.ex b/lib/wild/books/book.ex
index c2ba8fb..85b9a3e 100644
--- a/lib/wild/books/book.ex
+++ b/lib/wild/books/book.ex
@@ -6,7 +6,9 @@ defmodule Wild.Books.Book do
field :title, :string
field :blurb, :string
field :publication_year, :string
- field :author_id, :id
+
+ belongs_to :author, Wild.Books.Author
+ # field :author_id, :id
timestamps(type: :utc_datetime)
end
diff --git a/lib/wild_web/components/layouts/root.html.heex b/lib/wild_web/components/layouts/root.html.heex
index b1dc0a8..1592342 100644
--- a/lib/wild_web/components/layouts/root.html.heex
+++ b/lib/wild_web/components/layouts/root.html.heex
@@ -4,7 +4,7 @@
- <.live_title default="Wild" suffix=" ยท Phoenix Framework">
+ <.live_title default="Call of the Wild" suffix="">
{assigns[:page_title]}
diff --git a/priv/repo/migrations/20250109103126_create_book_reads.exs b/priv/repo/migrations/20250109103126_create_book_reads.exs
index 12525f1..ff51b42 100644
--- a/priv/repo/migrations/20250109103126_create_book_reads.exs
+++ b/priv/repo/migrations/20250109103126_create_book_reads.exs
@@ -2,14 +2,14 @@ defmodule Wild.Repo.Migrations.CreateBookReads do
use Ecto.Migration
def change do
- create table(:book_reads) do
+ create table(:book_reads, primary_key: false) 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)
+ add :user_id, references(:users, on_delete: :delete_all), primary_key: true
+ add :book_id, references(:books, on_delete: :delete_all), primary_key: true
timestamps(type: :utc_datetime)
end