Merge remote-tracking branch 'origin/main' into feature/308-web-form
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing

This commit is contained in:
Simon 2026-03-09 15:40:02 +01:00
commit ad6ef169ac
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
16 changed files with 642 additions and 220 deletions

View file

@ -22,6 +22,10 @@ defmodule Mv.Constants do
@boolean_filter_prefix "bf_"
@group_filter_prefix "group_"
@fee_type_filter_prefix "fee_type_"
@max_boolean_filters 50
@max_uuid_length 36
@ -70,6 +74,16 @@ defmodule Mv.Constants do
"""
def boolean_filter_prefix, do: @boolean_filter_prefix
@doc """
Returns the prefix for group filter URL parameters (e.g. group_<uuid>=in|not_in).
"""
def group_filter_prefix, do: @group_filter_prefix
@doc """
Returns the prefix for fee type filter URL parameters (e.g. fee_type_<uuid>=in|not_in).
"""
def fee_type_filter_prefix, do: @fee_type_filter_prefix
@doc """
Returns the maximum number of boolean custom field filters allowed per request.

View file

@ -6,6 +6,8 @@ defmodule Mv.Release do
## Tasks
- `migrate/0` - Runs all pending Ecto migrations.
- `run_seeds/0` - Runs bootstrap seeds (fee types, custom fields, roles, settings).
In production, set `RUN_DEV_SEEDS=true` to also run dev seeds (members, groups, sample data).
- `seed_admin/0` - Ensures an admin user exists from ENV (ADMIN_EMAIL, ADMIN_PASSWORD
or ADMIN_PASSWORD_FILE). Idempotent; can be run on every deployment or via shell
to update the admin password without redeploying.
@ -26,6 +28,40 @@ defmodule Mv.Release do
end
end
@doc """
Runs seed scripts so the database has required bootstrap data (and optionally dev data).
- Always runs bootstrap seeds (fee types, custom fields, roles, system user, settings).
- If `RUN_DEV_SEEDS` env is set to `"true"`, also runs dev seeds (members, groups, sample data).
Uses paths from the application's priv dir so it works in releases (no Mix). Idempotent.
"""
def run_seeds do
case Application.ensure_all_started(@app) do
{:ok, _} -> :ok
{:error, {app, reason}} -> raise "Failed to start #{inspect(app)}: #{inspect(reason)}"
end
priv = :code.priv_dir(@app)
bootstrap_path = Path.join(priv, "repo/seeds_bootstrap.exs")
dev_path = Path.join(priv, "repo/seeds_dev.exs")
prev = Code.compiler_options()
Code.compiler_options(ignore_module_conflict: true)
try do
Code.eval_file(bootstrap_path)
IO.puts("✅ Bootstrap seeds completed.")
if System.get_env("RUN_DEV_SEEDS") == "true" do
Code.eval_file(dev_path)
IO.puts("✅ Dev seeds completed.")
end
after
Code.compiler_options(prev)
end
end
def rollback(repo, version) do
load_app()
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))