Skip to content

Commit 84588bd

Browse files
d-csclaude
andauthored
feat(run-ops): dedicated run-ops database package + docker service + migration runner (#4113)
## What The **dedicated run-ops database** foundation for the split: a standalone Prisma package plus the infra to run and migrate it. - **`internal-packages/run-ops-database`** — a new Prisma package (`@internal/run-ops-database`) whose schema mirrors the run-execution tables that will live on the dedicated DB, with its own generated client, migrations, and migration runner. - **`prisma/schema.parity.test.ts`** — a parity test that guards the run-ops schema against drift from the control-plane schema for the mirrored tables. - **Docker** — a Postgres 17 service (`docker/Dockerfile.postgres17`, `docker/docker-compose.yml`) so the dedicated DB is available locally under the run-ops compose profile. - **Testcontainers** — hetero fixtures (PG14 legacy + PG17 dedicated) so later PRs can exercise cross-database behaviour with real containers rather than mocks. ## Why This is the **second PR in the run-ops split stack**, stacked on the core primitives. It stands up the dedicated database and its tooling. There is **no runtime wiring** into the webapp here — the app does not read or write this DB yet; that arrives in later PRs. On its own this PR only adds a package, a docker service, and test fixtures. ## Tests Schema-parity test for the run-ops schema; hetero testcontainer fixture smoke test. ## Notes - Draft, **stacked on #4112** (`runops/pr01-core-residency`). Review that one first; this diff is against it. - Server-change / changeset note to be added at stack-assembly time. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 4cfa596 commit 84588bd

20 files changed

Lines changed: 2181 additions & 45 deletions

File tree

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres?schema=publi
77
# This sets the URL used for direct connections to the database and should only be needed in limited circumstances
88
# See: https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#fields:~:text=the%20shadow%20database.-,directUrl,-No
99
DIRECT_URL=${DATABASE_URL}
10+
# Dedicated run-ops database (@internal/run-ops-database). Only needed to run prisma commands
11+
# against it or to enable the run-ops split; start it with `docker compose --profile runops up`.
12+
RUN_OPS_DATABASE_URL=postgresql://postgres:postgres@localhost:5434/postgres?schema=public
13+
RUN_OPS_DATABASE_DIRECT_URL=${RUN_OPS_DATABASE_URL}
1014
REMIX_APP_PORT=3030
1115
# Dev-only: stream the webapp's logs over a local telnet/TCP socket (nc localhost 6767). Uncomment to enable.
1216
# WEBAPP_TELNET_LOGS_PORT=6767

.github/workflows/unit-tests-internal.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ jobs:
9595
}
9696
echo "Pre-pulling Docker images with authenticated session..."
9797
pull postgres:14
98+
pull postgres:17 # for the heterogeneous PG14/17 test fixture gate (heteroPostgresTest)
9899
pull clickhouse/clickhouse-server:26.2.19.43-alpine@sha256:c6ad6a7eb2fb5999df3adfb8b69a0c7222c68fa9b8f6b04a088564ebbc959251
99100
pull redis:7.2
100101
pull testcontainers/ryuk:0.14.0

docker/Dockerfile.postgres17

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM postgres:17
2+
3+
RUN apt-get update \
4+
&& apt-get install -y --no-install-recommends postgresql-17-partman \
5+
&& rm -rf /var/lib/apt/lists/*

docker/docker-compose.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ name: triggerdotdev-docker
1111
volumes:
1212
database-data:
1313
database-data-alt:
14+
database-runops-data:
1415
database-replica-data:
1516
redis-data:
1617
minio-data:
@@ -51,6 +52,36 @@ services:
5152
- -c
5253
- max_connections=500
5354

55+
# Opt-in NEW run-ops database, PG17 (the `database` above is PG14) — a separate cluster
56+
# so the run-ops split's distinct-DB sentinel passes. Start with:
57+
# COMPOSE_PROFILES=runops pnpm run docker
58+
database-runops:
59+
container_name: ${CONTAINER_PREFIX:-}database-runops
60+
profiles: ["runops"]
61+
build:
62+
context: .
63+
dockerfile: Dockerfile.postgres17
64+
restart: always
65+
volumes:
66+
- ${DB_RUNOPS_VOLUME:-database-runops-data}:/var/lib/postgresql/data/
67+
environment:
68+
POSTGRES_USER: postgres
69+
POSTGRES_PASSWORD: postgres
70+
POSTGRES_DB: postgres
71+
networks:
72+
- app_network
73+
ports:
74+
- "${POSTGRES_RUNOPS_HOST_PORT:-5434}:5432"
75+
command:
76+
- -c
77+
- listen_addresses=*
78+
- -c
79+
- wal_level=logical
80+
- -c
81+
- shared_preload_libraries=pg_partman_bgw
82+
- -c
83+
- max_connections=500
84+
5485
# Opt-in streaming read replica with configurable apply lag — a dial-a-lag rig for
5586
# testing replica-race behavior (e.g. the realtime read-your-writes gate) locally.
5687
# Start with: COMPOSE_PROFILES=replica pnpm run docker
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.env
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
generated/run-ops
4+
5+
# Ensure the .env symlink is not removed by accident
6+
!.env
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@internal/run-ops-database",
3+
"private": true,
4+
"version": "0.0.1",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"@triggerdotdev/source": "./src/index.ts",
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/index.js",
12+
"default": "./dist/index.js"
13+
},
14+
"./prisma/schema.prisma": "./prisma/schema.prisma",
15+
"./prisma/*": "./prisma/*",
16+
"./package.json": "./package.json"
17+
},
18+
"dependencies": {
19+
"@prisma/client": "6.14.0",
20+
"prisma": "6.14.0"
21+
},
22+
"devDependencies": {
23+
"rimraf": "6.0.1",
24+
"vitest": "4.1.7"
25+
},
26+
"scripts": {
27+
"clean": "rimraf dist",
28+
"generate": "prisma generate",
29+
"db:migrate:dev:create": "prisma migrate dev --create-only",
30+
"db:migrate:deploy": "prisma migrate deploy",
31+
"db:push": "prisma db push",
32+
"test": "vitest run",
33+
"typecheck": "tsc --noEmit",
34+
"build": "pnpm run clean && tsc --noEmit false --outDir dist --declaration",
35+
"dev": "tsc --noEmit false --outDir dist --declaration --watch",
36+
"db:studio": "prisma studio",
37+
"db:reset": "prisma migrate reset"
38+
}
39+
}

0 commit comments

Comments
 (0)