chore: replace manual SQL migrations with node-pg-migrate
SonarQube Analysis / sonarqube (pull_request) Successful in 2m42s
Tests / backend-unit (pull_request) Successful in 34s
Tests / backend-integration (pull_request) Successful in 50s
Tests / frontend-e2e (pull_request) Failing after 38s

This commit is contained in:
2026-08-14 10:05:09 -05:00
parent 6ca3366821
commit 7f4479605a
8 changed files with 284 additions and 75 deletions
+14 -9
View File
@@ -35,18 +35,23 @@ npm run db:test:up
This starts Postgres on `localhost:55432`, database `redefined_test`.
### 2. Load the schema
### 2. Run migrations
**PowerShell:**
```powershell
Get-Content init.sql | docker exec -i redefined-designs-test-db psql -U redefined_test -d redefined_test
```
**PowerShell / bash (same command, cross-platform via Node):**
**bash:**
```bash
docker exec -i redefined-designs-test-db psql -U redefined_test -d redefined_test < init.sql
```
cd backend
$env:PGHOST="localhost"; $env:PGPORT="55432"; $env:PGUSER="redefined_test"; $env:PGPASSWORD="redefined_test"; $env:PGDATABASE="redefined_test"
npm install
npm run migrate:up
This applies every migration in `backend/migrations/` in order, tracked in a `pgmigrations` table so re-running is always safe (already-applied migrations are skipped).
To add a new migration:
npm run migrate:create -- descriptive-name
This generates a timestamped file in `backend/migrations/` with `exports.up`/`exports.down` stubs — fill in `pgm.sql(...)` for both directions.
### 3. Configure environment variables
**PowerShell:**