924 B · text History f20eaae
defmodule CartosnapApp.Photos.Photo do
  use Ecto.Schema
  import Ecto.Changeset

  @primary_key {:id, :binary_id, autogenerate: true}
  @foreign_key_type :binary_id
  schema "photo_photos" do
    field :blurhash, :string
    field :date, :date
    field :exif, :map
    field :filename, :string
    field :geo_point, :string
    field :name, :string
    field :promoted, :boolean, default: false
    field :url_full, :string
    field :url_original, :string
    field :url_preview, :string
    field :url_thumb, :string
    field :user, :binary_id

    timestamps()
  end

  @doc false
  def changeset(photo, attrs) do
    photo
    |> cast(attrs, [:name, :exif, :filename, :date, :url_original, :url_full, :url_preview, :url_thumb, :blurhash, :geo_point, :promoted])
    |> validate_required([:name, :exif, :filename, :date, :url_original, :url_full, :url_preview, :url_thumb, :blurhash, :geo_point, :promoted])
  end
end