Skip to content

Commit c0872b8

Browse files
committed
200 Database Migration Apply Lane
201 Promotion Lane 202 Backup / Restore 203 Drift Validation 204 Seed Separation 205 Owner Operations DB Tools 206 Database Runbook
1 parent 4ddc854 commit c0872b8

5 files changed

Lines changed: 518 additions & 1258 deletions

File tree

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# PR_26167_200-database-migration-apply-lane
2+
3+
Status: PASS
4+
5+
## Branch Validation
6+
7+
PASS - Current branch is `main`.
8+
9+
## Change Summary
10+
11+
- Updated `scripts/apply-database-ddl.mjs` into a repeatable database migration apply lane.
12+
- Added migration tracking through `schema_migrations`.
13+
- Applied top-level grouped SQL files from `docs_build/database/ddl` and `docs_build/database/dml`.
14+
- Updated `scripts/validate-runtime-connections.mjs` to validate `platform_settings` with the required identity tables.
15+
- Confirmed old script names remain compatibility wrappers only and print deprecation messages.
16+
17+
## Script Rename Evidence
18+
19+
PASS - Active validator is `scripts/validate-runtime-connections.mjs`.
20+
21+
PASS - Active database apply script is `scripts/apply-database-ddl.mjs`.
22+
23+
PASS - `scripts/validate-supabase-dev.mjs` prints:
24+
25+
```text
26+
Deprecated script name. Use validate-runtime-connections.mjs.
27+
```
28+
29+
PASS - `scripts/apply-supabase-dev-ddl.mjs` prints:
30+
31+
```text
32+
Deprecated script name. Use apply-database-ddl.mjs.
33+
```
34+
35+
## Schema Migrations Evidence
36+
37+
PASS - `schema_migrations` exists.
38+
39+
PASS - Required tracking columns exist:
40+
41+
```text
42+
key,fileName,migrationType,checksum,appliedAt,appliedBy
43+
```
44+
45+
PASS - Tracked migration counts:
46+
47+
```text
48+
DDL count=15
49+
DML count=15
50+
```
51+
52+
PASS - Required tables confirmed in the configured database:
53+
54+
```text
55+
users
56+
roles
57+
user_roles
58+
platform_settings
59+
schema_migrations
60+
```
61+
62+
## DDL/DML Apply Evidence
63+
64+
PASS - Initial apply during this PR execution created migration tracking and applied all top-level grouped SQL files:
65+
66+
```text
67+
Database migrations processed=30; applied=30; skipped=0.
68+
```
69+
70+
PASS - Current repeat apply is idempotent and skips already-applied unchanged files:
71+
72+
```text
73+
Database migrations processed=30; applied=0; skipped=30.
74+
```
75+
76+
PASS - Checksum drift is guarded in `scripts/apply-database-ddl.mjs`; an already-applied migration with a different checksum throws a visible error instructing the operator to create a new migration file.
77+
78+
## Requirement Checklist
79+
80+
PASS - Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` before execution.
81+
82+
PASS - Hard stop branch guard satisfied; current branch is `main`.
83+
84+
PASS - Finished the database DDL/DML apply lane before storage/R2 work.
85+
86+
PASS - Active script names are `validate-runtime-connections.mjs` and `apply-database-ddl.mjs`.
87+
88+
PASS - Compatibility wrappers remain only for continuity and print deprecation messages.
89+
90+
PASS - Validation and DDL apply load `.env` only.
91+
92+
PASS - Database connection behavior uses `GAMEFOUNDRY_DATABASE_URL` and `GAMEFOUNDRY_DATABASE_SSL`.
93+
94+
PASS - `schema_migrations` is created/confirmed.
95+
96+
PASS - Migration tracking records file name, type, checksum, applied timestamp, and applied actor.
97+
98+
PASS - Already-applied unchanged files are skipped.
99+
100+
PASS - Already-applied changed checksums fail visibly.
101+
102+
PASS - No environment parameters were introduced.
103+
104+
PASS - No DEV/IST/UAT/PRD branching was introduced.
105+
106+
PASS - No SQLite/local-db/mock-db fallback was introduced.
107+
108+
PASS - No R2/storage work was included.
109+
110+
## Validation Lane Report
111+
112+
PASS - `node --check scripts\apply-database-ddl.mjs`
113+
114+
PASS - `node --check scripts\validate-runtime-connections.mjs`
115+
116+
PASS - `node .\scripts\validate-runtime-connections.mjs`
117+
118+
```text
119+
Overall Result: PASS
120+
Database SSL mode: disable
121+
Database connection host=192.168.2.5 port=55431 database=gamefoundry_dev
122+
users table PASS
123+
roles table PASS
124+
user_roles table PASS
125+
platform_settings table PASS
126+
```
127+
128+
PASS - `node .\scripts\apply-database-ddl.mjs`
129+
130+
```text
131+
.env loaded for database migration apply
132+
schema_migrations table confirmed
133+
Migration tracking fields: fileName, migrationType, checksum, appliedAt, appliedBy
134+
Database migrations processed=30; applied=0; skipped=30.
135+
```
136+
137+
PASS - `node .\scripts\validate-runtime-connections.mjs` after apply.
138+
139+
PASS - Direct configured database query confirmed required tables and migration counts.
140+
141+
PASS - Compatibility wrapper validation:
142+
143+
```text
144+
node .\scripts\validate-supabase-dev.mjs
145+
node .\scripts\apply-supabase-dev-ddl.mjs
146+
```
147+
148+
PASS - Changed script forbidden-marker scan found no provider variables, old database URL, SQLite/local-db/mock-db fallback, environment parameter markers, or R2/storage references in the PR200 script scope.
149+
150+
SKIP - Full samples smoke was not run because this PR only changes database validation/apply scripts and does not touch sample runtime behavior.
151+
152+
## Manual Validation Notes
153+
154+
- Migration apply reads only top-level `.sql` files directly under `docs_build/database/ddl` and `docs_build/database/dml`.
155+
- Nested archived or legacy SQL folders were not pulled into the active migration lane.
156+
- No secrets were written to reports; database evidence uses host, port, and database name only.
157+
- No browser, UI, Playwright, storage/R2, or runtime product feature files were changed.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
docs_build/dev/PROJECT_INSTRUCTIONS.md
2-
package.json
3-
scripts/validate-runtime-connections.mjs
41
scripts/apply-database-ddl.mjs
5-
scripts/validate-supabase-dev.mjs
6-
scripts/apply-supabase-dev-ddl.mjs
7-
docs_build/dev/reports/PR_26167_199-env-copy-source-governance.md
2+
scripts/validate-runtime-connections.mjs
3+
docs_build/dev/reports/PR_26167_200-database-migration-apply-lane.md
84
docs_build/dev/reports/codex_review.diff
95
docs_build/dev/reports/codex_changed_files.txt

0 commit comments

Comments
 (0)