Pre/post scripts
Pre-scripts
Section titled “Pre-scripts”File location: schema/pre/<name>.sql
Run before schema migration, in alphabetical order. Use for data cleanup, temporary table setup, or anything that needs to happen before DDL.
-- schema/pre/001_cleanup.sqlDELETE FROM temp_data WHERE created_at < now() - interval '30 days';Post-scripts
Section titled “Post-scripts”File location: schema/post/<name>.sql
Run after schema migration, in alphabetical order. Use for view refreshes, data backfills, or cache warming.
-- schema/post/001_refresh_views.sqlREFRESH MATERIALIZED VIEW CONCURRENTLY user_stats;Creating templates
Section titled “Creating templates”npx @smplcty/schema-flow new pre --name cleanupnpx @smplcty/schema-flow new post --name refresh-viewsCreates timestamped template files like schema/pre/20240115120000_cleanup.sql.
File tracking
Section titled “File tracking”All files (YAML and SQL) are tracked by SHA-256 hash. A file is re-run only when its content changes. There is no distinction between one-shot and repeatable scripts — everything is hash-tracked uniformly.
Execution phases
Section titled “Execution phases”| Phase | When |
|---|---|
| Pre-scripts | Phase 1 (after internal schema setup, before extensions) |
| Post-scripts | Phase 16 (after seeds, last phase) |