berrypod/lib/berrypod/release.ex
jamey 5b41f3fedf extract site_name and site_description from theme settings into standalone settings
site_name and site_description are shop identity, not theme concerns.
They now live in the Settings table as first-class settings with their
own assigns (@site_name, @site_description) piped through hooks and
plugs. The setup wizard writes site_name on account creation, and the
theme editor reads/writes via Settings.put_setting. Removed the
"configure your shop" checklist item since currency/country aren't
built yet. Also adds shop name field to setup wizard step 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 14:52:31 +00:00

52 lines
1.2 KiB
Elixir

defmodule Berrypod.Release do
@moduledoc """
Release tasks that can be run via `bin/migrate` or `bin/berrypod eval`.
Migrations run automatically on startup (see Application), so this is mainly
useful as a standalone tool for debugging or manual recovery.
"""
@app :berrypod
def migrate do
load_app()
for repo <- repos() do
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
end
end
@doc """
Seeds default theme settings if none exist.
Called on every boot but only writes to the DB on first run
(when the settings table is empty). Safe to call repeatedly.
"""
def seed_defaults do
alias Berrypod.Settings
case Settings.get_setting("theme_settings") do
nil ->
{:ok, _} = Settings.apply_preset(:studio, skip_customised_flag: true)
:ok
_exists ->
:ok
end
end
def rollback(repo, version) do
load_app()
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
end
defp repos do
Application.fetch_env!(@app, :ecto_repos)
end
defp load_app do
Application.ensure_all_started(:ssl)
Application.load(@app)
end
end