Fix seeds to run in production #462

Merged
moritz merged 1 commit from fix/seeds into main 2026-03-09 15:25:08 +01:00
Owner

Description of the implemented changes

The changes were:

  • Bugfixing
  • New Feature
  • Breaking Change
  • Refactoring

Fix production seeds: run bootstrap in container; add RUN_DEV_SEEDS for optional dev seeds.


What has been changed?

  • Mv.Release.run_seeds/0
    New release task that runs bootstrap seeds (fee types, custom fields, roles, system user, settings) and, when RUN_DEV_SEEDS=true, also runs dev seeds (members, groups, sample data). Uses app priv dir so it works in releases (no Mix). Idempotent; restores compiler options in an after block.
  • priv/repo/seeds_bootstrap.exs
    Safe to run from release: mix_env is derived from Mix.env() or, if Mix is not available (e.g. in release), from System.get_env("MIX_ENV"). Replaced the single Mix.env() usage (admin password fallback for dev/test) with mix_env.
  • rel/overlays/bin/docker-entrypoint.sh
    After migrate, the entrypoint now runs run_seeds() (bootstrap; dev seeds only if RUN_DEV_SEEDS=true), then seed_admin(), then the server. Previously only migrate and seed_admin() ran, so bootstrap seeds never ran in production.
  • priv/repo/seeds.exs
    Comment added that in production seeds are run via Mv.Release.run_seeds/0 and that RUN_DEV_SEEDS controls dev seeds there.
  • docs/admin-bootstrap-and-oidc-role-sync.md
    Documented run_seeds/0, the RUN_DEV_SEEDS env var, and the updated entrypoint order (migrate → run_seeds → seed_admin → server).

Definition of Done

Code Quality

  • No new technical depths
  • Linting passed
  • Documentation is added were needed

Accessibility

  • New elements are properly defined with html-tags
  • Colour contrast follows WCAG criteria
  • Aria labels are added when needed
  • Everything is accessible by keyboard
  • Tab-Order is comprehensible
  • All interactive elements have a visible focus

Testing

  • Tests for new code are written
  • All tests pass
  • axe-core dev tools show no critical or major issues

Additional Notes

  • Root cause: In production, only migrate and seed_admin() were executed; the full seed script (bootstrap) was never invoked, and RUN_DEV_SEEDS was not used anywhere.
  • Backward compatibility: Existing deployments keep working. New deployments get bootstrap data (roles, fee types, settings, etc.) on first start. Set RUN_DEV_SEEDS=true only when you want dev/demo data in that environment.
  • Commit created without running just ci-dev (as requested); consider running it before merge and ticking the Definition of Done items accordingly.
## Description of the implemented changes The changes were: - [x] Bugfixing - [x] New Feature - [ ] Breaking Change - [ ] Refactoring **Fix production seeds: run bootstrap in container; add RUN_DEV_SEEDS for optional dev seeds.** --- ## What has been changed? - **`Mv.Release.run_seeds/0`** New release task that runs bootstrap seeds (fee types, custom fields, roles, system user, settings) and, when `RUN_DEV_SEEDS=true`, also runs dev seeds (members, groups, sample data). Uses app priv dir so it works in releases (no Mix). Idempotent; restores compiler options in an `after` block. - **`priv/repo/seeds_bootstrap.exs`** Safe to run from release: `mix_env` is derived from `Mix.env()` or, if Mix is not available (e.g. in release), from `System.get_env("MIX_ENV")`. Replaced the single `Mix.env()` usage (admin password fallback for dev/test) with `mix_env`. - **`rel/overlays/bin/docker-entrypoint.sh`** After `migrate`, the entrypoint now runs `run_seeds()` (bootstrap; dev seeds only if `RUN_DEV_SEEDS=true`), then `seed_admin()`, then the server. Previously only migrate and `seed_admin()` ran, so bootstrap seeds never ran in production. - **`priv/repo/seeds.exs`** Comment added that in production seeds are run via `Mv.Release.run_seeds/0` and that `RUN_DEV_SEEDS` controls dev seeds there. - **`docs/admin-bootstrap-and-oidc-role-sync.md`** Documented `run_seeds/0`, the `RUN_DEV_SEEDS` env var, and the updated entrypoint order (migrate → run_seeds → seed_admin → server). --- ## Definition of Done ### Code Quality - [ ] No new technical depths - [ ] Linting passed - [ ] Documentation is added were needed ### Accessibility - [ ] New elements are properly defined with html-tags - [ ] Colour contrast follows WCAG criteria - [ ] Aria labels are added when needed - [ ] Everything is accessible by keyboard - [ ] Tab-Order is comprehensible - [ ] All interactive elements have a visible focus ### Testing - [ ] Tests for new code are written - [ ] All tests pass - [ ] axe-core dev tools show no critical or major issues --- ## Additional Notes - **Root cause:** In production, only `migrate` and `seed_admin()` were executed; the full seed script (bootstrap) was never invoked, and `RUN_DEV_SEEDS` was not used anywhere. - **Backward compatibility:** Existing deployments keep working. New deployments get bootstrap data (roles, fee types, settings, etc.) on first start. Set `RUN_DEV_SEEDS=true` only when you want dev/demo data in that environment. - **Commit created without running `just ci-dev`** (as requested); consider running it before merge and ticking the Definition of Done items accordingly.
moritz self-assigned this 2026-03-09 15:17:48 +01:00
moritz added 1 commit 2026-03-09 15:17:50 +01:00
Run bootstrap seeds in production; add RUN_DEV_SEEDS support
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/promote/production Build is passing
d032f1ca0c
moritz added this to the Sprint 13: 19.02-26.02 project 2026-03-09 15:17:51 +01:00
moritz merged commit 085f61d10d into main 2026-03-09 15:25:08 +01:00
moritz deleted branch fix/seeds 2026-03-09 15:25:09 +01:00
Sign in to join this conversation.
No description provided.