ddd_domain/bootstrap
2026-08-16 10:32:42 +02:00
..
README.md [HOP] Initial commit (release: 0.0.0) 2026-08-16 10:32:42 +02:00

Bootstrap Scripts

This directory contains data initialization scripts executed on empty databases.

File Naming

Files are named with alphabetic prefixes for execution order:

  • 01-init-roles.sql
  • 02-seed-config.py
  • 03-reference-data.sql

Files are executed alphabetically (not numerically parsed).

Execution Context

Bootstrap scripts run:

  • Development: Each patch apply (allows iteration on bootstrap)
  • Production: Initial clone only (one-time setup)

For production data changes, use patches (not bootstrap).

Python Files

Python files can define a run(model) function to share the database connection:

def run(model):
    # model is the halfORM Model instance with active connection
    MyModel = model.get_relation_class('schema.table')
    MyModel(field='value').ho_insert()

Without run(model), the file executes as a subprocess (must handle own connection).

SQL Files

SQL files can use any SQL commands:

-- Initialize roles
INSERT INTO public.roles (name) VALUES ('admin'), ('user');

Notes

  • No tracking mechanism (files execute on every restore)
  • Not idempotent (assumes empty database)
  • Maintained manually by developers