@@ -24,12 +24,19 @@ npm run container:build:db-job
2424The image entrypoint is ` node scripts/db-sqlserver-admin.mjs ` , so Compose or
2525manual runs pass the admin command as arguments:
2626
27- - ` bootstrap ` creates the database plus the app and job SQL principals.
27+ - ` bootstrap ` creates the database plus distinct app and job SQL principals,
28+ their ` dbo ` default schema, and the ` kravhantering_runtime ` role membership.
29+ Password rotation is outside this command's scope.
2830- ` migration-status ` prints JSON evidence with expected, observed, pending and
2931 unknown TypeORM migrations without modifying the database.
30- - ` migrate ` applies TypeORM migrations.
32+ - ` migrate ` applies TypeORM migrations, reconciles the runtime permission
33+ manifest, and fails if grants or managed-user membership do not verify.
3134- ` migrate --json ` applies TypeORM migrations and prints the preflight,
32- applied migration and post-migration evidence as JSON.
35+ migration execution, final migration status, and runtime-permission evidence
36+ as JSON.
37+ - ` permission-status ` prints secret-free JSON evidence without changing state.
38+ - ` permission-reconcile ` reapplies the manifest and managed memberships, then
39+ prints the verified JSON status.
3340- ` seed:required ` applies only required system and lookup seed data.
3441- ` health ` runs a simple SQL Server read check.
3542- ` wait ` polls SQL Server until it responds.
@@ -39,6 +46,25 @@ A production-like empty database is bootstrap, migration, and
3946its required seed helper modules, and excludes ` typeorm/seed.mjs ` , dogfood
4047seed, archiving-retention demo seed, tests, and documentation.
4148
49+ [ ` runtime-permission-manifest.mjs ` ] ( ../../typeorm/runtime-permission-manifest.mjs )
50+ is the release-versioned authority for exact object, operation, and
51+ column-scoped grants. New objects require manifest inclusion for access through
52+ the custom ` kravhantering_runtime ` role. Within the custom role, the runtime can
53+ read but not write ` dbo.migrations ` ; protected audit and review tables have
54+ narrower insert, update-column, and delete boundaries. The reconciler removes
55+ unexpected direct permissions from the project role. For every managed runtime
56+ user, it establishes and verifies the custom grants and membership. If that
57+ user also belongs to ` db_datareader ` or ` db_datawriter ` , the reconciler removes
58+ those broad memberships only after the custom contract verifies. It does not
59+ modify other user roles, direct user grants, or site-owned extension-role
60+ memberships. Verification nevertheless fails when those permissions give a
61+ managed runtime user effective schema-migration or protected-audit mutation
62+ access. Custom-role parent nesting also fails verification for an operator to
63+ resolve explicitly. Migrations and required seed continue to use the separate
64+ db-job login with ` db_owner ` . Reconciliation, broad-role removal, and final
65+ effective-permission verification commit as one transaction; a final failure
66+ leaves no partial permission or membership changes.
67+
4268The image installs only the dependency subset needed by the one-shot job:
4369` mssql ` , ` typeorm ` , and ` reflect-metadata ` . It deliberately does not include
4470the Next.js application dependency tree.
@@ -53,6 +79,10 @@ Required values:
5379
5480- ` DB_HOST ` , ` DB_PORT ` , ` DB_NAME ` , ` DB_USER ` , and ` DB_PASSWORD ` select the
5581 SQL Server database used for migrations and required seed data.
82+ - ` DB_RUNTIME_USER ` names the application runtime database user whose custom-role
83+ membership must verify. It is non-secret and never authorizes login creation,
84+ password rotation, or a runtime connection. Additional managed users may be
85+ listed comma-separated in ` DB_RUNTIME_USERS ` .
5686- ` DB_ENCRYPT ` and ` DB_TRUST_SERVER_CERTIFICATE ` configure the SQL Server TLS
5787 connection.
5888- ` DB_CONNECTION_TIMEOUT_MS ` and ` DB_REQUEST_TIMEOUT_MS ` bound database
0 commit comments