berrypod/lib/simpleshop_theme/settings/setting.ex
Jamey Greenwood a401365943 feat: add Settings and Media contexts with theme settings schema
- Create settings table for site-wide key-value configuration
- Create images table for BLOB storage of logo/header images
- Add Setting schema with JSON/string/integer/boolean support
- Add ThemeSettings embedded schema with all theme options
- Add Settings context with get/put/update operations
- Add Media context for image uploads and retrieval
- Add Image schema with SVG detection and storage
- Add 9 curated theme presets (gallery, studio, boutique, etc.)
- Add comprehensive tests for Settings and Media contexts
- Add seeds with default Studio preset
- All tests passing (29 tests, 0 failures)
2025-12-30 21:35:52 +00:00

25 lines
616 B
Elixir

defmodule SimpleshopTheme.Settings.Setting do
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema "settings" do
field :key, :string
field :value, :string
field :value_type, :string, default: "string"
timestamps(type: :utc_datetime)
end
@doc false
def changeset(setting, attrs) do
setting
|> cast(attrs, [:key, :value, :value_type])
|> validate_required([:key, :value, :value_type])
|> validate_inclusion(:value_type, ~w(string json integer boolean))
|> unique_constraint(:key)
end
end