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)
This commit is contained in:
16
priv/repo/migrations/20251230213057_create_settings.exs
Normal file
16
priv/repo/migrations/20251230213057_create_settings.exs
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule SimpleshopTheme.Repo.Migrations.CreateSettings do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:settings, primary_key: false) do
|
||||
add :id, :binary_id, primary_key: true
|
||||
add :key, :string, null: false
|
||||
add :value, :text, null: false
|
||||
add :value_type, :string, null: false, default: "string"
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create unique_index(:settings, [:key])
|
||||
end
|
||||
end
|
||||
21
priv/repo/migrations/20251230213058_create_images.exs
Normal file
21
priv/repo/migrations/20251230213058_create_images.exs
Normal file
@@ -0,0 +1,21 @@
|
||||
defmodule SimpleshopTheme.Repo.Migrations.CreateImages do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:images, primary_key: false) do
|
||||
add :id, :binary_id, primary_key: true
|
||||
add :image_type, :string, null: false
|
||||
add :filename, :string, null: false
|
||||
add :content_type, :string, null: false
|
||||
add :file_size, :integer, null: false
|
||||
add :data, :binary, null: false
|
||||
add :is_svg, :boolean, default: false
|
||||
add :svg_content, :text
|
||||
add :thumbnail_data, :binary
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:images, [:image_type])
|
||||
end
|
||||
end
|
||||
@@ -9,3 +9,12 @@
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
|
||||
alias SimpleshopTheme.Settings
|
||||
|
||||
# Set default theme settings (Studio preset)
|
||||
IO.puts("Setting up default theme settings...")
|
||||
|
||||
{:ok, _theme} = Settings.apply_preset(:studio)
|
||||
|
||||
IO.puts("✓ Default theme settings applied (Studio preset)")
|
||||
|
||||
Reference in New Issue
Block a user