521 B · text History df5dc2a
defmodule FeedPug.Schema do
  @moduledoc """
  Base schema for FeedPug: UUIDv7 (time-ordered) binary primary keys with
  binary foreign keys. `use FeedPug.Schema` in place of `use Ecto.Schema`.

  Primary keys are autogenerated app-side as UUIDv7, so they sort by creation
  time — good index locality without leaking a sequential counter.
  """
  defmacro __using__(_opts) do
    quote do
      use Ecto.Schema

      @primary_key {:id, UUIDv7, autogenerate: true}
      @foreign_key_type :binary_id
    end
  end
end