defmodule Wild.Repo.Migrations.CreateBookReads do
  use Ecto.Migration

  def change 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: :delete_all), primary_key: true
      add :book_id, references(:books, on_delete: :delete_all), primary_key: true

      timestamps(type: :utc_datetime)
    end

    create index(:book_reads, [:user_id])
    create index(:book_reads, [:book_id])
  end
end
