Story: SQL directory refactor
Table of Contents
This page documents a story in Sprint 10. It captures the goal, current status, acceptance criteria, and the tasks that compose it.
Goal
Reorganise create/, drop/, populate/ into component-based
subdirectories with consistent naming; harden teardown; clean up
deprecated files.
Status
| Field | Value |
|---|---|
| State | DONE |
| Parent sprint | Sprint 10 |
| Now | Completed 2026-01-24. |
| Waiting on | None. |
| Next | None. |
| Last touched | 2026-01-24 |
Acceptance
create/,drop/,populate/follow the same component layout.- Production teardown requires explicit reviewable scripts.
- Admin objects follow
admin_*_fn/admin_*_viewconvention. - 56 files moved with git-history preserved.
- Stale entries removed.
Tasks
| Task | State | Start | End | Description |
|---|---|---|---|---|
| Restructure SQL create/, drop/, teardown | DONE | 2026-05-19 | 2026-01-24 | create/ reorganised into component-based subdirectories with master scripts; safer teardown (admin_teardown_instances_generate.sql for production); ER diagram updated with the new tables. |
| Refactor drop/ and populate/ directory structure | DONE | 2026-05-19 | 2026-01-24 | 56 files relocated into component subdirectories with git-history preserved; consistent naming (drop_COMPONENT.sql, populate_COMPONENT.sql); monolithic seed_upsert_functions split per component. |
| Refactor coding schemes and clean up ores.sql | DONE | 2026-05-19 | 2026-01-24 | Schema/ renamed to create/; deprecated files removed; admin objects follow admin_*_fn/admin_*_view convention; database_name_service updated to the new function names. |
Decisions
- Three PRs, not one
- each refactor stands on its own; merging them would have produced an unreviewable diff.
- Explicit teardown scripts
- removed the pattern-match path that was the source of accidental-drop risk.
Out of scope
- Schema-per-component (the metadata/production split is enough).
See also
- ores.sql — the component this story restructures.