mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-07-27 22:45:03 +00:00
feat(ara-projects): seed project_type and workstream reference data
Adds migration 0274, a data-only custom SQL migration seeding the two reference tables the setup wizard needs (#407): - project_type: Retrofit, Planned Maintenance - workstream: the canonical 8 from the UX wireframes, each with a one-line description (the column is NOT NULL) Note that #407 specifies the second project type as "New Build"; PR review superseded that with "Planned Maintenance". The ticket text is stale, not the code. Idempotency uses INSERT ... SELECT ... WHERE NOT EXISTS rather than ON CONFLICT DO NOTHING, because neither table has a unique constraint on `name` — an ON CONFLICT (name) form would fail at runtime with "no unique or exclusion constraint matching the ON CONFLICT specification". Re-running is a no-op and leaves existing rows, including edited descriptions, alone. The 0274 snapshot is a copy of 0273 with chained id/prevId, matching how the previous data-only migration (0227) was recorded. No UI for creating workstreams — deferred to #428. UNVERIFIED AGAINST A LIVE DATABASE. This environment's DB credentials point at production, so the migration was deliberately not executed. It was verified statically only: both statements parse against the PostgreSQL grammar (libpg_query), the target tables and columns were cross-checked against the 0273 schema snapshot, every NOT NULL column without a default is supplied, and the seeded values match the intended set exactly. A human needs to run it against a non-production database and confirm both the fresh-DB and re-run cases before it ships. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a0680b0eea
commit
a1ecbd0fc0
3 changed files with 13155 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
-- Seed the project_type and workstream reference tables (issue #407).
|
||||
--
|
||||
-- Neither table has a unique constraint on `name`, so idempotency is expressed
|
||||
-- with NOT EXISTS rather than ON CONFLICT. Re-running is a no-op; existing rows
|
||||
-- are left untouched, including any hand-edited description.
|
||||
|
||||
INSERT INTO project_type (name)
|
||||
SELECT v.name
|
||||
FROM (VALUES
|
||||
('Retrofit'),
|
||||
('Planned Maintenance')
|
||||
) AS v(name)
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM project_type pt WHERE pt.name = v.name
|
||||
);
|
||||
--> statement-breakpoint
|
||||
INSERT INTO workstream (name, description)
|
||||
SELECT v.name, v.description
|
||||
FROM (VALUES
|
||||
('Windows', 'Replacement and repair of windows, including glazing upgrades.'),
|
||||
('Doors', 'Replacement and repair of external, internal and communal doors.'),
|
||||
('Roofs', 'Roof covering replacement and repair, including rainwater goods.'),
|
||||
('Kitchens', 'Replacement and refurbishment of kitchens.'),
|
||||
('Bathrooms', 'Replacement and refurbishment of bathrooms and wet rooms.'),
|
||||
('Asbestos', 'Asbestos survey, management, encapsulation and removal works.'),
|
||||
('Electrical heating', 'Installation and upgrade of electrical heating systems and controls.'),
|
||||
('Cyclical decorations', 'Planned cyclical internal and external decoration.')
|
||||
) AS v(name, description)
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM workstream w WHERE w.name = v.name
|
||||
);
|
||||
13117
src/app/db/migrations/meta/0274_snapshot.json
Normal file
13117
src/app/db/migrations/meta/0274_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1912,6 +1912,13 @@
|
|||
"when": 1784546553566,
|
||||
"tag": "0273_normal_bloodstrike",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 274,
|
||||
"version": "7",
|
||||
"when": 1784631274000,
|
||||
"tag": "0274_seed_project_type_and_workstream",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue