@marinoscar/platform-db 0.0.0-stage → 0.1.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/LICENSE +21 -0
- package/README.md +525 -2
- package/bin/platform.js +28 -0
- package/dist/baseline/deps.d.ts +32 -0
- package/dist/baseline/deps.d.ts.map +1 -0
- package/dist/baseline/deps.js +66 -0
- package/dist/baseline/deps.js.map +1 -0
- package/dist/baseline/errors.d.ts +36 -0
- package/dist/baseline/errors.d.ts.map +1 -0
- package/dist/baseline/errors.js +23 -0
- package/dist/baseline/errors.js.map +1 -0
- package/dist/baseline/fs.d.ts +9 -0
- package/dist/baseline/fs.d.ts.map +1 -0
- package/dist/baseline/fs.js +39 -0
- package/dist/baseline/fs.js.map +1 -0
- package/dist/baseline/index.d.ts +8 -0
- package/dist/baseline/index.d.ts.map +1 -0
- package/dist/baseline/index.js +24 -0
- package/dist/baseline/index.js.map +1 -0
- package/dist/baseline/mapping.d.ts +43 -0
- package/dist/baseline/mapping.d.ts.map +1 -0
- package/dist/baseline/mapping.js +80 -0
- package/dist/baseline/mapping.js.map +1 -0
- package/dist/baseline/normalise.d.ts +42 -0
- package/dist/baseline/normalise.d.ts.map +1 -0
- package/dist/baseline/normalise.js +133 -0
- package/dist/baseline/normalise.js.map +1 -0
- package/dist/baseline/plan.d.ts +66 -0
- package/dist/baseline/plan.d.ts.map +1 -0
- package/dist/baseline/plan.js +105 -0
- package/dist/baseline/plan.js.map +1 -0
- package/dist/baseline/report.d.ts +127 -0
- package/dist/baseline/report.d.ts.map +1 -0
- package/dist/baseline/report.js +89 -0
- package/dist/baseline/report.js.map +1 -0
- package/dist/baseline/run.d.ts +117 -0
- package/dist/baseline/run.d.ts.map +1 -0
- package/dist/baseline/run.js +358 -0
- package/dist/baseline/run.js.map +1 -0
- package/dist/bin/db-commands.d.ts +31 -0
- package/dist/bin/db-commands.d.ts.map +1 -0
- package/dist/bin/db-commands.js +311 -0
- package/dist/bin/db-commands.js.map +1 -0
- package/dist/bin/fs-io.d.ts +7 -0
- package/dist/bin/fs-io.d.ts.map +1 -0
- package/dist/bin/fs-io.js +45 -0
- package/dist/bin/fs-io.js.map +1 -0
- package/dist/bin/platform.d.ts +21 -0
- package/dist/bin/platform.d.ts.map +1 -0
- package/dist/bin/platform.js +99 -0
- package/dist/bin/platform.js.map +1 -0
- package/dist/compose/api.d.ts +84 -0
- package/dist/compose/api.d.ts.map +1 -0
- package/dist/compose/api.js +101 -0
- package/dist/compose/api.js.map +1 -0
- package/dist/compose/compose.d.ts +51 -0
- package/dist/compose/compose.d.ts.map +1 -0
- package/dist/compose/compose.js +177 -0
- package/dist/compose/compose.js.map +1 -0
- package/dist/compose/diff.d.ts +7 -0
- package/dist/compose/diff.d.ts.map +1 -0
- package/dist/compose/diff.js +68 -0
- package/dist/compose/diff.js.map +1 -0
- package/dist/compose/errors.d.ts +31 -0
- package/dist/compose/errors.d.ts.map +1 -0
- package/dist/compose/errors.js +35 -0
- package/dist/compose/errors.js.map +1 -0
- package/dist/compose/index.d.ts +3 -0
- package/dist/compose/index.d.ts.map +1 -0
- package/dist/compose/index.js +11 -0
- package/dist/compose/index.js.map +1 -0
- package/dist/compose/parse.d.ts +65 -0
- package/dist/compose/parse.d.ts.map +1 -0
- package/dist/compose/parse.js +122 -0
- package/dist/compose/parse.js.map +1 -0
- package/dist/drift/app-objects.d.ts +107 -0
- package/dist/drift/app-objects.d.ts.map +1 -0
- package/dist/drift/app-objects.js +193 -0
- package/dist/drift/app-objects.js.map +1 -0
- package/dist/drift/db-conformance.d.ts +52 -0
- package/dist/drift/db-conformance.d.ts.map +1 -0
- package/dist/drift/db-conformance.js +89 -0
- package/dist/drift/db-conformance.js.map +1 -0
- package/dist/drift/index.d.ts +8 -0
- package/dist/drift/index.d.ts.map +1 -0
- package/dist/drift/index.js +43 -0
- package/dist/drift/index.js.map +1 -0
- package/dist/drift/raw-sql-indexes.d.ts +106 -0
- package/dist/drift/raw-sql-indexes.d.ts.map +1 -0
- package/dist/drift/raw-sql-indexes.js +113 -0
- package/dist/drift/raw-sql-indexes.js.map +1 -0
- package/dist/drift/raw-sql-tripwire.d.ts +191 -0
- package/dist/drift/raw-sql-tripwire.d.ts.map +1 -0
- package/dist/drift/raw-sql-tripwire.js +422 -0
- package/dist/drift/raw-sql-tripwire.js.map +1 -0
- package/dist/drift/rls-policies.d.ts +226 -0
- package/dist/drift/rls-policies.d.ts.map +1 -0
- package/dist/drift/rls-policies.js +317 -0
- package/dist/drift/rls-policies.js.map +1 -0
- package/dist/drift/run.d.ts +152 -0
- package/dist/drift/run.d.ts.map +1 -0
- package/dist/drift/run.js +252 -0
- package/dist/drift/run.js.map +1 -0
- package/dist/drift/sql-expression.d.ts +27 -0
- package/dist/drift/sql-expression.d.ts.map +1 -0
- package/dist/drift/sql-expression.js +64 -0
- package/dist/drift/sql-expression.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/lock/hash.d.ts +13 -0
- package/dist/lock/hash.d.ts.map +1 -0
- package/dist/lock/hash.js +19 -0
- package/dist/lock/hash.js.map +1 -0
- package/dist/lock/index.d.ts +5 -0
- package/dist/lock/index.d.ts.map +1 -0
- package/dist/lock/index.js +20 -0
- package/dist/lock/index.js.map +1 -0
- package/dist/lock/lock.d.ts +154 -0
- package/dist/lock/lock.d.ts.map +1 -0
- package/dist/lock/lock.js +151 -0
- package/dist/lock/lock.js.map +1 -0
- package/dist/lock/manifest.d.ts +68 -0
- package/dist/lock/manifest.d.ts.map +1 -0
- package/dist/lock/manifest.js +96 -0
- package/dist/lock/manifest.js.map +1 -0
- package/dist/lock/semver.d.ts +10 -0
- package/dist/lock/semver.d.ts.map +1 -0
- package/dist/lock/semver.js +13 -0
- package/dist/lock/semver.js.map +1 -0
- package/dist/seed/index.d.ts +5 -0
- package/dist/seed/index.d.ts.map +1 -0
- package/dist/seed/index.js +16 -0
- package/dist/seed/index.js.map +1 -0
- package/dist/seed/input.d.ts +52 -0
- package/dist/seed/input.d.ts.map +1 -0
- package/dist/seed/input.js +77 -0
- package/dist/seed/input.js.map +1 -0
- package/dist/seed/seed-platform.d.ts +41 -0
- package/dist/seed/seed-platform.d.ts.map +1 -0
- package/dist/seed/seed-platform.js +165 -0
- package/dist/seed/seed-platform.js.map +1 -0
- package/dist/seed/steps.d.ts +172 -0
- package/dist/seed/steps.d.ts.map +1 -0
- package/dist/seed/steps.js +136 -0
- package/dist/seed/steps.js.map +1 -0
- package/dist/seed/types.d.ts +287 -0
- package/dist/seed/types.d.ts.map +1 -0
- package/dist/seed/types.js +5 -0
- package/dist/seed/types.js.map +1 -0
- package/dist/sync/app-migrations.d.ts +52 -0
- package/dist/sync/app-migrations.d.ts.map +1 -0
- package/dist/sync/app-migrations.js +62 -0
- package/dist/sync/app-migrations.js.map +1 -0
- package/dist/sync/apply.d.ts +29 -0
- package/dist/sync/apply.d.ts.map +1 -0
- package/dist/sync/apply.js +38 -0
- package/dist/sync/apply.js.map +1 -0
- package/dist/sync/check.d.ts +59 -0
- package/dist/sync/check.d.ts.map +1 -0
- package/dist/sync/check.js +115 -0
- package/dist/sync/check.js.map +1 -0
- package/dist/sync/errors.d.ts +32 -0
- package/dist/sync/errors.d.ts.map +1 -0
- package/dist/sync/errors.js +23 -0
- package/dist/sync/errors.js.map +1 -0
- package/dist/sync/index.d.ts +10 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +27 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/ledger.d.ts +65 -0
- package/dist/sync/ledger.d.ts.map +1 -0
- package/dist/sync/ledger.js +49 -0
- package/dist/sync/ledger.js.map +1 -0
- package/dist/sync/plan.d.ts +63 -0
- package/dist/sync/plan.d.ts.map +1 -0
- package/dist/sync/plan.js +86 -0
- package/dist/sync/plan.js.map +1 -0
- package/dist/sync/promote.d.ts +62 -0
- package/dist/sync/promote.d.ts.map +1 -0
- package/dist/sync/promote.js +95 -0
- package/dist/sync/promote.js.map +1 -0
- package/dist/sync/timestamps.d.ts +41 -0
- package/dist/sync/timestamps.d.ts.map +1 -0
- package/dist/sync/timestamps.js +68 -0
- package/dist/sync/timestamps.js.map +1 -0
- package/dist/sync/version.d.ts +28 -0
- package/dist/sync/version.d.ts.map +1 -0
- package/dist/sync/version.js +66 -0
- package/dist/sync/version.js.map +1 -0
- package/migrations/0001_initial/migration.sql +297 -0
- package/migrations/0002_add_personal_access_tokens/migration.sql +31 -0
- package/migrations/0003_add_credentials/migration.sql +20 -0
- package/migrations/0004_add_notification_deliveries/migration.sql +27 -0
- package/migrations/0005_drop_stale_uuid_defaults/migration.sql +35 -0
- package/migrations/0006_add_notifications/migration.sql +22 -0
- package/migrations/0007_add_push_subscriptions/migration.sql +25 -0
- package/migrations/0008_add_jobs/migration.sql +110 -0
- package/migrations/0009_add_worker_nodes/migration.sql +90 -0
- package/migrations/0010_add_database_backup_runs/migration.sql +104 -0
- package/migrations/0011_add_notification_broadcasts/migration.sql +57 -0
- package/migrations/0012_add_backup_run_job_link/migration.sql +87 -0
- package/migrations/0013_add_job_node_secrets/migration.sql +61 -0
- package/migrations/0014_add_backup_run_pg_dump_version/migration.sql +26 -0
- package/migrations/0015_add_job_claim_token/migration.sql +92 -0
- package/migrations/0016_add_ai_platform/migration.sql +108 -0
- package/migrations/0017_revoke_viewer_ai_use/migration.sql +32 -0
- package/migrations/0018_add_user_credentials/migration.sql +29 -0
- package/migrations/0019_add_device_session_credential_link/migration.sql +52 -0
- package/migrations/0020_add_worker_node_vitals/migration.sql +3 -0
- package/migrations/0021_add_job_trace_context/migration.sql +6 -0
- package/migrations/0022_add_retention_created_at_indexes/migration.sql +13 -0
- package/migrations/0023_add_organizations/migration.sql +142 -0
- package/migrations/0024_split_system_org_roles/migration.sql +131 -0
- package/migrations/0025_org_scoped_rls/migration.sql +215 -0
- package/migrations/0026_add_groups/migration.sql +165 -0
- package/migrations/0027_add_grants/migration.sql +117 -0
- package/migrations/0028_add_org_settings/migration.sql +49 -0
- package/migrations/0029_add_org_credentials/migration.sql +54 -0
- package/migrations/0030_add_jobs_org_id/migration.sql +18 -0
- package/migrations/0031_add_jobs_org_id_status_index/migration.sql +6 -0
- package/migrations/0032_add_broadcast_target_org/migration.sql +21 -0
- package/migrations/0033_add_android_app/migration.sql +60 -0
- package/migrations/0034_open_job_reason/migration.sql +16 -0
- package/migrations/0035_ai_usage_feature/migration.sql +37 -0
- package/migrations/0036_add_app_metadata/migration.sql +49 -0
- package/migrations/0037_open_sharing_vocabularies/migration.sql +97 -0
- package/migrations/manifest.json +379 -0
- package/package.json +78 -4
- package/raw-sql-indexes.json +94 -0
- package/rls-policies.json +74 -0
- package/schema/ai.prisma +444 -0
- package/schema/android-app.prisma +47 -0
- package/schema/base.prisma +11 -0
- package/schema/credentials.prisma +170 -0
- package/schema/db-backup.prisma +376 -0
- package/schema/identity.prisma +439 -0
- package/schema/jobs.prisma +760 -0
- package/schema/notifications.prisma +649 -0
- package/schema/settings.prisma +60 -0
- package/schema/sharing.prisma +223 -0
- package/schema/storage.prisma +84 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BASELINE_RUNBOOK = void 0;
|
|
4
|
+
exports.readOperatorMap = readOperatorMap;
|
|
5
|
+
exports.resolveThrough = resolveThrough;
|
|
6
|
+
exports.runBaseline = runBaseline;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const node_os_1 = require("node:os");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const index_js_1 = require("../drift/index.js");
|
|
12
|
+
const index_js_2 = require("../lock/index.js");
|
|
13
|
+
const index_js_3 = require("../sync/index.js");
|
|
14
|
+
const errors_js_1 = require("./errors.js");
|
|
15
|
+
const fs_js_1 = require("./fs.js");
|
|
16
|
+
const mapping_js_1 = require("./mapping.js");
|
|
17
|
+
const normalise_js_1 = require("./normalise.js");
|
|
18
|
+
const plan_js_1 = require("./plan.js");
|
|
19
|
+
/**
|
|
20
|
+
* The runbook the refusals point to.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
exports.BASELINE_RUNBOOK = 'docs/runbooks/database-baseline.md';
|
|
25
|
+
const mapSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.string().min(1));
|
|
26
|
+
/**
|
|
27
|
+
* Reads an operator `--map` file.
|
|
28
|
+
*
|
|
29
|
+
* @param file - Path of a JSON object mapping `platform:NNNN_slug` to a directory name.
|
|
30
|
+
* @returns The mapping.
|
|
31
|
+
* @throws BaselineError `MAP_INVALID` when the file is not a JSON object of strings.
|
|
32
|
+
* @stability experimental
|
|
33
|
+
*/
|
|
34
|
+
function readOperatorMap(file) {
|
|
35
|
+
let raw;
|
|
36
|
+
try {
|
|
37
|
+
raw = JSON.parse((0, node_fs_1.readFileSync)(file, 'utf8'));
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new errors_js_1.BaselineError('MAP_INVALID', `${file} could not be read as JSON: ${error.message}`);
|
|
41
|
+
}
|
|
42
|
+
const parsed = mapSchema.safeParse(raw);
|
|
43
|
+
if (!parsed.success)
|
|
44
|
+
throw new errors_js_1.BaselineError('MAP_INVALID', `${file} must be a JSON object of "platform:NNNN_slug": "localDirectory" pairs`);
|
|
45
|
+
return parsed.data;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Finds the `--through` entry.
|
|
49
|
+
*
|
|
50
|
+
* @param manifest - The package history.
|
|
51
|
+
* @param through - `22`, `0022`, `0022_slug` or `platform:0022_slug`; omitted means the newest.
|
|
52
|
+
* @returns The entry.
|
|
53
|
+
* @throws BaselineError `THROUGH_UNKNOWN`.
|
|
54
|
+
* @stability experimental
|
|
55
|
+
*/
|
|
56
|
+
function resolveThrough(manifest, through) {
|
|
57
|
+
if (manifest.length === 0)
|
|
58
|
+
throw new errors_js_1.BaselineError('THROUGH_UNKNOWN', 'the package has no migrations');
|
|
59
|
+
if (through === undefined)
|
|
60
|
+
return manifest[manifest.length - 1];
|
|
61
|
+
const bare = through.replace(/^platform:/, '');
|
|
62
|
+
const found = /^\d{1,4}$/.test(bare)
|
|
63
|
+
? manifest.find((entry) => (0, plan_js_1.sequenceOf)(entry.id) === Number(bare))
|
|
64
|
+
: manifest.find((entry) => entry.id === bare);
|
|
65
|
+
if (!found) {
|
|
66
|
+
throw new errors_js_1.BaselineError('THROUGH_UNKNOWN', `--through ${through} is no package migration (the history runs ${manifest[0].id} .. ${manifest[manifest.length - 1].id})`);
|
|
67
|
+
}
|
|
68
|
+
return found;
|
|
69
|
+
}
|
|
70
|
+
/** Rows that never completed and were not superseded by a later successful run of the same migration. */
|
|
71
|
+
function failedRows(rows) {
|
|
72
|
+
const good = new Set(rows.filter((r) => r.finishedAt && !r.rolledBackAt).map((r) => r.migrationName));
|
|
73
|
+
return rows.filter((r) => (!r.finishedAt || r.rolledBackAt) && !good.has(r.migrationName));
|
|
74
|
+
}
|
|
75
|
+
function emptyReport(through) {
|
|
76
|
+
return {
|
|
77
|
+
through,
|
|
78
|
+
matched: [],
|
|
79
|
+
toResolve: [],
|
|
80
|
+
toInstall: [],
|
|
81
|
+
appOnly: [],
|
|
82
|
+
unmatched: [],
|
|
83
|
+
diff: { allowed: [], blocking: [] },
|
|
84
|
+
indexProblems: [],
|
|
85
|
+
policyProblems: [],
|
|
86
|
+
ledger: { managed: true, problems: [] },
|
|
87
|
+
refusals: [],
|
|
88
|
+
notes: [],
|
|
89
|
+
actions: [],
|
|
90
|
+
lockUpToDate: false,
|
|
91
|
+
applied: false,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function buildLock(plan, previous, version) {
|
|
95
|
+
const base = (0, index_js_2.emptyLock)(version);
|
|
96
|
+
const migrations = plan.map((p) => ({
|
|
97
|
+
originId: p.originId,
|
|
98
|
+
localDir: p.localDir,
|
|
99
|
+
sha256: p.sha256,
|
|
100
|
+
since: p.since,
|
|
101
|
+
...(p.localSha256 ? { localSha256: p.localSha256, note: p.note } : {}),
|
|
102
|
+
}));
|
|
103
|
+
return {
|
|
104
|
+
...base,
|
|
105
|
+
migrations,
|
|
106
|
+
...(previous?.deviations ? { deviations: previous.deviations } : {}),
|
|
107
|
+
...(previous?.rawSqlIndexes ? { rawSqlIndexes: previous.rawSqlIndexes } : {}),
|
|
108
|
+
...(previous?.rlsPolicies ? { rlsPolicies: previous.rlsPolicies } : {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* `platform db baseline`: adopts the package history in a database that
|
|
113
|
+
* already has its schema, without re-running a migration (ADR 0002 D4).
|
|
114
|
+
*
|
|
115
|
+
* B1 maps the package migrations to the app's directories; B2 checks the
|
|
116
|
+
* `_prisma_migrations` ledger; B3 diffs the package history replayed to
|
|
117
|
+
* `--through` against the live database; B4 asserts the raw-SQL indexes in
|
|
118
|
+
* `pg_indexes`; B5 writes `platform.lock`, installs the migrations that have
|
|
119
|
+
* no directory and marks the ones at or below `--through` applied with
|
|
120
|
+
* `prisma migrate resolve --applied`; B6 verifies.
|
|
121
|
+
*
|
|
122
|
+
* Without `apply` nothing is written and `prisma` is never called. It never
|
|
123
|
+
* creates, drops or alters a database object, and there is no `--force`: any
|
|
124
|
+
* live difference no deviation declares refuses the baseline.
|
|
125
|
+
*
|
|
126
|
+
* @param opts - See {@link BaselineOptions}.
|
|
127
|
+
* @param deps - The injected effects.
|
|
128
|
+
* @returns The report; check `refusals` and `verify` (see `isBaselineClean`).
|
|
129
|
+
* @throws BaselineError for a bad `--through`, a bad `--map`, a failed `migrate resolve` or a corrupt package file; refusals found by the checks are returned in the report instead.
|
|
130
|
+
* @stability experimental
|
|
131
|
+
*/
|
|
132
|
+
async function runBaseline(opts, deps) {
|
|
133
|
+
const migrationsDir = (0, node_path_1.join)(opts.appPrismaDir, 'migrations');
|
|
134
|
+
const lockFile = (0, node_path_1.join)(opts.appPrismaDir, 'platform.lock');
|
|
135
|
+
const manifestFile = (0, node_path_1.join)(opts.packageDir, 'migrations', 'manifest.json');
|
|
136
|
+
if (!(0, node_fs_1.existsSync)(manifestFile))
|
|
137
|
+
throw new errors_js_1.BaselineError('THROUGH_UNKNOWN', `${manifestFile} does not exist; is --package-dir the @marinoscar/platform-db package?`);
|
|
138
|
+
const manifest = (0, index_js_2.parseManifest)((0, node_fs_1.readFileSync)(manifestFile, 'utf8'), manifestFile);
|
|
139
|
+
const packageVersion = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(opts.packageDir, 'package.json'), 'utf8')).version;
|
|
140
|
+
// The lock records the package version (a prerelease is fine) but never less than the newest `since` it holds.
|
|
141
|
+
const version = manifest.reduce((best, e) => ((0, index_js_3.compareVersions)(e.since, best) > 0 ? e.since : best), packageVersion);
|
|
142
|
+
const throughEntry = resolveThrough(manifest, opts.through);
|
|
143
|
+
const through = (0, plan_js_1.sequenceOf)(throughEntry.id);
|
|
144
|
+
const report = emptyReport((0, index_js_2.originIdOf)(throughEntry));
|
|
145
|
+
const refuse = (code, message) => {
|
|
146
|
+
report.refusals.push({ code, message });
|
|
147
|
+
};
|
|
148
|
+
const packageBytes = (entry) => (0, node_fs_1.readFileSync)((0, node_path_1.join)(opts.packageDir, 'migrations', entry.dir, 'migration.sql'));
|
|
149
|
+
// The package must be intact before anything is compared with it.
|
|
150
|
+
for (const entry of manifest) {
|
|
151
|
+
const actual = (0, index_js_2.sha256Hex)(packageBytes(entry));
|
|
152
|
+
if (actual !== entry.sha256) {
|
|
153
|
+
throw new errors_js_1.BaselineError('PACKAGE_FILE_MISMATCH', `${(0, index_js_2.originIdOf)(entry)}: package file hashes to ${actual.slice(0, 12)}, the manifest says ${entry.sha256.slice(0, 12)}; reinstall the package`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const existingLock = (0, node_fs_1.existsSync)(lockFile) ? (0, index_js_2.parseLock)((0, node_fs_1.readFileSync)(lockFile, 'utf8'), lockFile) : undefined;
|
|
157
|
+
const lockHasEntries = (existingLock?.migrations.length ?? 0) > 0;
|
|
158
|
+
if (lockHasEntries) {
|
|
159
|
+
if (opts.apply && !opts.forceRemap) {
|
|
160
|
+
refuse('LOCK_NOT_EMPTY', `platform.lock already has ${existingLock.migrations.length} entr${existingLock.migrations.length === 1 ? 'y' : 'ies'}; pass --force-remap to replace them (the mapping is recomputed from the files)`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// The classic trap first: a failed or rolled-back row makes everything below untrustworthy.
|
|
164
|
+
const ledger = await deps.readLedger();
|
|
165
|
+
report.ledger.managed = ledger !== undefined;
|
|
166
|
+
const bad = ledger ? failedRows(ledger) : [];
|
|
167
|
+
if (bad.length > 0) {
|
|
168
|
+
for (const row of bad) {
|
|
169
|
+
const why = row.rolledBackAt ? 'rolled back' : 'never finished';
|
|
170
|
+
report.ledger.problems.push(`${row.migrationName}: ${why}`);
|
|
171
|
+
}
|
|
172
|
+
refuse('LEDGER_FAILED_ROW', `_prisma_migrations has ${bad.length} failed or rolled-back row(s) (${bad.map((r) => r.migrationName).join(', ')}); resolve them with prisma migrate resolve first. See ${exports.BASELINE_RUNBOOK}, "A failed migration row"`);
|
|
173
|
+
return report;
|
|
174
|
+
}
|
|
175
|
+
// Stop before a migration that enables row-level security until the app opts in.
|
|
176
|
+
const rlsAbove = manifest.filter((e) => e.rls === true && (0, plan_js_1.sequenceOf)(e.id) > through);
|
|
177
|
+
if (rlsAbove.length > 0 && opts.allowRls !== true) {
|
|
178
|
+
refuse('RLS_OPT_IN_REQUIRED', `${rlsAbove.map(index_js_2.originIdOf).join(', ')} enable${rlsAbove.length === 1 ? 's' : ''} row-level security and sit above --through; the baseline stops before ${rlsAbove.length === 1 ? 'it' : 'them'} until you opt in with --allow-rls. First make the application role NOSUPERUSER NOBYPASSRLS (a superuser ignores every policy), add org_id to your own tenant tables, then re-run. See ${exports.BASELINE_RUNBOOK}, "Row-level security"`);
|
|
179
|
+
}
|
|
180
|
+
// B1 map.
|
|
181
|
+
const operatorMap = opts.mapFile ? readOperatorMap(opts.mapFile) : {};
|
|
182
|
+
const local = (0, fs_js_1.readLocalMigrations)(migrationsDir);
|
|
183
|
+
const matched = (0, mapping_js_1.proposeMapping)(manifest, local, packageBytes, operatorMap);
|
|
184
|
+
const matchedDirs = new Set(matched.map((m) => m.localDir));
|
|
185
|
+
const matchedIds = new Set(matched.map((m) => m.originId));
|
|
186
|
+
report.matched = matched;
|
|
187
|
+
report.unmatched = manifest.filter((e) => !matchedIds.has((0, index_js_2.originIdOf)(e))).map(index_js_2.originIdOf);
|
|
188
|
+
report.appOnly = [...local.keys()].filter((d) => !matchedDirs.has(d)).sort();
|
|
189
|
+
for (const m of matched.filter((x) => x.kind !== 'sha256')) {
|
|
190
|
+
report.notes.push(`${m.originId} matched ${m.localDir} by ${m.kind}, not by identical bytes: review it`);
|
|
191
|
+
}
|
|
192
|
+
// B2 ledger.
|
|
193
|
+
const recorded = new Set();
|
|
194
|
+
if (ledger) {
|
|
195
|
+
const byName = new Map(ledger.filter((r) => r.finishedAt && !r.rolledBackAt).map((r) => [r.migrationName, r]));
|
|
196
|
+
for (const m of matched) {
|
|
197
|
+
if ((0, plan_js_1.sequenceOf)(m.originId.slice('platform:'.length)) > through)
|
|
198
|
+
continue; // pending locally; deploy applies it
|
|
199
|
+
const row = byName.get(m.localDir);
|
|
200
|
+
if (!row) {
|
|
201
|
+
report.ledger.problems.push(`${m.originId}: ${m.localDir} is not a finished row of _prisma_migrations`);
|
|
202
|
+
refuse('LEDGER_ROW_MISSING', `${m.originId}: ${m.localDir} has no finished row in _prisma_migrations, so the database never applied it; lower --through or apply it first`);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
recorded.add(m.localDir);
|
|
206
|
+
const want = (0, index_js_2.sha256Hex)(local.get(m.localDir));
|
|
207
|
+
if (row.checksum !== want) {
|
|
208
|
+
report.ledger.problems.push(`${m.originId}: ${m.localDir} differs from what the database applied`);
|
|
209
|
+
refuse('LEDGER_CHECKSUM_MISMATCH', `${m.originId}: the file ${m.localDir} hashes to ${want.slice(0, 12)} but the database recorded ${row.checksum.slice(0, 12)}; the file was edited after it was applied`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
report.notes.push('the database has no _prisma_migrations table (Prisma never managed it): every migration up to --through is recorded with migrate resolve --applied. App-only directories are NOT resolved by the baseline; resolve them yourself before the first migrate deploy');
|
|
215
|
+
}
|
|
216
|
+
// The plan (also names the directories that will be created).
|
|
217
|
+
let plan = [];
|
|
218
|
+
try {
|
|
219
|
+
plan = (0, plan_js_1.planBaseline)(manifest, matched, (0, fs_js_1.listDirs)(migrationsDir), through, recorded, deps.now());
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
if (!(error instanceof errors_js_1.BaselineError))
|
|
223
|
+
throw error;
|
|
224
|
+
refuse(error.code, error.message.replace(/^[A-Z_]+: /, ''));
|
|
225
|
+
}
|
|
226
|
+
report.toResolve = plan
|
|
227
|
+
.filter((p) => p.resolve)
|
|
228
|
+
.map((p) => ({ originId: p.originId, localDir: p.localDir, install: p.action !== 'mapped' }));
|
|
229
|
+
report.toInstall = plan.filter((p) => p.action === 'install').map((p) => ({ originId: p.originId, localDir: p.localDir }));
|
|
230
|
+
if (existingLock && plan.length > 0) {
|
|
231
|
+
report.lockUpToDate = (0, index_js_2.serializeLock)(buildLock(plan, existingLock, existingLock.platformVersion)) === (0, index_js_2.serializeLock)(existingLock);
|
|
232
|
+
}
|
|
233
|
+
if (lockHasEntries && !opts.apply && !report.lockUpToDate) {
|
|
234
|
+
report.notes.push(`platform.lock already has ${existingLock.migrations.length} entries that differ from this plan; --apply needs --force-remap to replace them`);
|
|
235
|
+
}
|
|
236
|
+
// B3 diff: the package history up to --through, replayed, against the LIVE database.
|
|
237
|
+
const deviations = existingLock?.deviations ?? [];
|
|
238
|
+
const replayRoot = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'platform-baseline-replay-'));
|
|
239
|
+
try {
|
|
240
|
+
const replay = (0, node_path_1.join)(replayRoot, 'migrations');
|
|
241
|
+
(0, node_fs_1.mkdirSync)(replay, { recursive: true });
|
|
242
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(replay, 'migration_lock.toml'), 'provider = "postgresql"\n');
|
|
243
|
+
for (const entry of manifest.filter((e) => (0, plan_js_1.sequenceOf)(e.id) <= through)) {
|
|
244
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(replay, entry.dir));
|
|
245
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(replay, entry.dir, 'migration.sql'), packageBytes(entry));
|
|
246
|
+
}
|
|
247
|
+
const statements = (0, normalise_js_1.splitStatements)(await deps.diffReplayToLive(replay));
|
|
248
|
+
const declared = new Set(deviations.flatMap((d) => d.expectDiff.map(normalise_js_1.normaliseStatement)));
|
|
249
|
+
const used = new Set();
|
|
250
|
+
for (const statement of statements) {
|
|
251
|
+
const normal = (0, normalise_js_1.normaliseStatement)(statement);
|
|
252
|
+
if (declared.has(normal)) {
|
|
253
|
+
used.add(normal);
|
|
254
|
+
report.diff.allowed.push(normal);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
report.diff.blocking.push(normal);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
for (const d of deviations) {
|
|
261
|
+
if (!d.expectDiff.every((s) => used.has((0, normalise_js_1.normaliseStatement)(s)))) {
|
|
262
|
+
report.notes.push(`deviation ${d.id} declares a statement the diff no longer prints; remove it from platform.lock when it is resolved`);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
(0, node_fs_1.rmSync)(replayRoot, { recursive: true, force: true });
|
|
268
|
+
}
|
|
269
|
+
if (report.diff.blocking.length > 0) {
|
|
270
|
+
refuse('DIFF_BLOCKING', `the live database differs from the package history up to ${report.through} in ${report.diff.blocking.length} statement(s); fix the differences with ordinary forward migrations, declare an intended alteration under "deviations" in platform.lock, or lower --through. See ${exports.BASELINE_RUNBOOK}, "Fixing differences"`);
|
|
271
|
+
}
|
|
272
|
+
// B4 raw-SQL indexes: a positive assertion, because Prisma's diff ignores partial and expression indexes.
|
|
273
|
+
const packageIndexesFile = (0, node_path_1.join)(opts.packageDir, 'raw-sql-indexes.json');
|
|
274
|
+
const expected = [
|
|
275
|
+
...((0, node_fs_1.existsSync)(packageIndexesFile) ? (0, index_js_1.readPackageRawSqlIndexes)(packageIndexesFile) : []).filter((i) => (0, plan_js_1.sequenceOf)(i.createdIn) <= through),
|
|
276
|
+
...(existingLock?.rawSqlIndexes ?? []),
|
|
277
|
+
];
|
|
278
|
+
report.indexProblems = (0, index_js_1.checkRawSqlIndexes)(expected, await deps.readIndexes());
|
|
279
|
+
for (const problem of report.indexProblems)
|
|
280
|
+
refuse(problem.code, problem.message);
|
|
281
|
+
// B4 row-level security: the same positive assertion for the policies the history up to --through creates
|
|
282
|
+
// (Prisma's diff ignores policies and their enabled/forced flags in both directions).
|
|
283
|
+
if (deps.readPolicies && deps.readTableRls) {
|
|
284
|
+
const packagePoliciesFile = (0, node_path_1.join)(opts.packageDir, 'rls-policies.json');
|
|
285
|
+
const expectedPolicies = [
|
|
286
|
+
...((0, node_fs_1.existsSync)(packagePoliciesFile) ? (0, index_js_1.readPackageRlsPolicies)(packagePoliciesFile) : []).filter((p) => (0, plan_js_1.sequenceOf)(p.createdIn) <= through),
|
|
287
|
+
...(existingLock?.rlsPolicies ?? []),
|
|
288
|
+
];
|
|
289
|
+
report.policyProblems = (0, index_js_1.checkRlsPolicies)(expectedPolicies, await deps.readPolicies(), await deps.readTableRls());
|
|
290
|
+
for (const problem of report.policyProblems)
|
|
291
|
+
refuse(problem.code, problem.message);
|
|
292
|
+
}
|
|
293
|
+
// Output of the dry run; nothing below runs without --apply or with a refusal.
|
|
294
|
+
if (report.refusals.length > 0 || !opts.apply)
|
|
295
|
+
return report;
|
|
296
|
+
// B5 act, in package order so a predecessor exists before its successor is placed.
|
|
297
|
+
let current; // the directory created for the step in flight
|
|
298
|
+
try {
|
|
299
|
+
for (const p of plan) {
|
|
300
|
+
if (p.action !== 'mapped') {
|
|
301
|
+
(0, fs_js_1.installMigration)(migrationsDir, p.localDir, packageBytes(manifest.find((e) => (0, index_js_2.originIdOf)(e) === p.originId)));
|
|
302
|
+
current = p.localDir;
|
|
303
|
+
report.actions.push(`install ${p.localDir} <- ${p.originId}`);
|
|
304
|
+
deps.log(`install ${p.localDir}`);
|
|
305
|
+
}
|
|
306
|
+
if (p.resolve) {
|
|
307
|
+
deps.log(`prisma migrate resolve --applied ${p.localDir}`);
|
|
308
|
+
const result = await deps.prisma(['migrate', 'resolve', '--applied', p.localDir]);
|
|
309
|
+
if (result.status !== 0) {
|
|
310
|
+
throw new errors_js_1.BaselineError('RESOLVE_FAILED', `prisma migrate resolve --applied ${p.localDir} failed (exit ${result.status}): ${(result.stderr || result.stdout).trim().split('\n').slice(0, 4).join(' ')}`);
|
|
311
|
+
}
|
|
312
|
+
report.actions.push(`resolve --applied ${p.localDir}`);
|
|
313
|
+
}
|
|
314
|
+
current = undefined;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
// The lock is written last, so a failure leaves none. Take back the directory of the step that failed: it
|
|
319
|
+
// was created here and is not in the ledger; earlier ones are recorded and a re-run maps them by hash.
|
|
320
|
+
if (current)
|
|
321
|
+
(0, fs_js_1.removeInstalled)(migrationsDir, current);
|
|
322
|
+
throw error;
|
|
323
|
+
}
|
|
324
|
+
const lock = buildLock(plan, existingLock, version);
|
|
325
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(lockFile), { recursive: true });
|
|
326
|
+
(0, node_fs_1.writeFileSync)(lockFile, (0, index_js_2.serializeLock)(lock));
|
|
327
|
+
report.actions.push(`write platform.lock (${lock.migrations.length} entries)`);
|
|
328
|
+
deps.log(`wrote ${lockFile}`);
|
|
329
|
+
report.applied = true;
|
|
330
|
+
// B6 verify: Prisma's own status, the offline check and the ledger comparison.
|
|
331
|
+
const problems = [];
|
|
332
|
+
const status = await deps.prisma(['migrate', 'status']);
|
|
333
|
+
const pendingOnly = report.toInstall.map((i) => i.localDir);
|
|
334
|
+
if (status.status !== 0) {
|
|
335
|
+
const listed = status.stdout.split('\n').map((l) => l.trim()).filter((l) => /^\d{14}_\S+$/.test(l));
|
|
336
|
+
const expectedPending = pendingOnly.length > 0 && listed.length === pendingOnly.length && pendingOnly.every((d) => listed.includes(d));
|
|
337
|
+
if (!expectedPending)
|
|
338
|
+
problems.push(`prisma migrate status failed: ${(status.stdout + status.stderr).trim().split('\n').slice(-6).join(' | ')}`);
|
|
339
|
+
}
|
|
340
|
+
else if (pendingOnly.length > 0) {
|
|
341
|
+
problems.push('prisma migrate status reports nothing pending, but migrations above --through were installed');
|
|
342
|
+
}
|
|
343
|
+
const afterLocal = (0, fs_js_1.readLocalMigrations)(migrationsDir);
|
|
344
|
+
const lockCheck = (0, index_js_3.checkLock)(manifest, lock, (dir) => afterLocal.get(dir), (dir) => ((0, node_fs_1.existsSync)((0, node_path_1.join)(opts.packageDir, 'migrations', dir, 'migration.sql')) ? (0, node_fs_1.readFileSync)((0, node_path_1.join)(opts.packageDir, 'migrations', dir, 'migration.sql')) : undefined));
|
|
345
|
+
for (const p of lockCheck.problems)
|
|
346
|
+
problems.push(`${p.code} ${p.message}`);
|
|
347
|
+
const rows = (await deps.readLedger()) ?? [];
|
|
348
|
+
const ledgerCheck = (0, index_js_3.checkLedger)([...afterLocal.keys()], (dir) => afterLocal.get(dir), rows);
|
|
349
|
+
for (const p of ledgerCheck.problems)
|
|
350
|
+
problems.push(`${p.code} ${p.message}`);
|
|
351
|
+
const allowedPending = new Set(pendingOnly);
|
|
352
|
+
const unexpected = ledgerCheck.pending.filter((d) => !allowedPending.has(d));
|
|
353
|
+
if (unexpected.length > 0)
|
|
354
|
+
report.notes.push(`${unexpected.length} app directory(ies) are not applied yet (prisma migrate deploy applies them): ${unexpected.join(', ')}`);
|
|
355
|
+
report.verify = { ok: problems.length === 0, problems };
|
|
356
|
+
return report;
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/baseline/run.ts"],"names":[],"mappings":";;;AAqHA,0CAUC;AAWD,wCAWC;AAmED,kCAiPC;AAzcD,qCAAkG;AAClG,qCAAiC;AACjC,yCAA0C;AAC1C,6BAAwB;AACxB,gDAQ2B;AAC3B,+CAU0B;AAC1B,+CAA2F;AAC3F,2CAA4C;AAC5C,mCAA2F;AAC3F,6CAA8C;AAC9C,iDAAqE;AACrE,uCAAwE;AAGxE;;;;GAIG;AACU,QAAA,gBAAgB,GAAG,oCAAoC,CAAC;AAsErE,MAAM,SAAS,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,IAAI,GAAY,CAAC;IACjB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,yBAAa,CAAC,aAAa,EAAE,GAAG,IAAI,+BAAgC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3G,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,M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AM,cAAc,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,iFAAiF,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3K,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;IACxD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Output sinks and environment of the `platform db` commands, injectable so tests drive them.
|
|
4
|
+
*
|
|
5
|
+
* @stability experimental
|
|
6
|
+
*/
|
|
7
|
+
export interface DbCommandContext {
|
|
8
|
+
/** Writes a line to standard output. */
|
|
9
|
+
out: (line: string) => void;
|
|
10
|
+
/** Writes a line to standard error. */
|
|
11
|
+
err: (line: string) => void;
|
|
12
|
+
/** The working directory; the default for `--root`. */
|
|
13
|
+
cwd: string;
|
|
14
|
+
/** The environment (`DATABASE_URL`, `SHADOW_DATABASE_URL`). */
|
|
15
|
+
env: NodeJS.ProcessEnv;
|
|
16
|
+
/** The clock for new migration timestamps. */
|
|
17
|
+
now: () => Date;
|
|
18
|
+
/** The package root holding `migrations/`, `raw-sql-indexes.json` and `package.json`. */
|
|
19
|
+
packageRoot: string;
|
|
20
|
+
/** Receives the exit code of the finished command. */
|
|
21
|
+
setExitCode: (code: number) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Registers `sync`, `check`, `promote`, `drift`, `policies` and `baseline` on the `platform db` command.
|
|
25
|
+
*
|
|
26
|
+
* @param db - The `db` subcommand of the `platform` program.
|
|
27
|
+
* @param ctx - Output sinks and environment.
|
|
28
|
+
* @stability experimental
|
|
29
|
+
*/
|
|
30
|
+
export declare function registerDbSyncCommands(db: Command, ctx: DbCommandContext): void;
|
|
31
|
+
//# sourceMappingURL=db-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-commands.d.ts","sourceRoot":"","sources":["../../src/bin/db-commands.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAczC;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,uCAAuC;IACvC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,8CAA8C;IAC9C,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,yFAAyF;IACzF,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAiSD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,gBAAgB,GAAG,IAAI,CA8D/E"}
|