defmodule Odinsea.Database.Schema.NxCode do @moduledoc """ Ecto schema for the nxcode table. Represents NX (cash) redemption codes. """ use Ecto.Schema import Ecto.Changeset @primary_key {:code, :string, autogenerate: false} schema "nxcode" do field :valid, :integer, default: 1 field :user, :string field :type, :integer, default: 0 field :item, :integer, default: 10000 end @doc """ Changeset for creating/updating an NX code. """ def changeset(nx_code, attrs) do nx_code |> cast(attrs, [:code, :valid, :user, :type, :item]) |> validate_required([:code]) end end