Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+8
-8
@@ -8,14 +8,11 @@
|
||||
* interface so the CLI package stays free of `@prisma/client`. Production
|
||||
* callers wire up a real client in `bin/hivegrid-cli.mjs`; tests pass a fake.
|
||||
*
|
||||
* Foreign-key remapping: only the `tenantId` column is rewritten. Row primary
|
||||
* keys are preserved (the snapshot is intended to land in a separate
|
||||
* Foreign-key remapping: direct tenant rows receive the target `tenantId`;
|
||||
* FK-derived children keep their original foreign keys because parent primary
|
||||
* keys are preserved. The snapshot is intended to land in a separate
|
||||
* environment, so id collisions with other tenants in that target are not
|
||||
* the concern this commit addresses; the schema's tenant-scoped uniqueness
|
||||
* indexes do the rest). The roadmap notes (`tenant-snapshot.md` step 6) call
|
||||
* out a deeper FK-aware remapper as a follow-up if cross-tenant FK chains
|
||||
* ever appear (today none of the tenant-scoped models cross-reference each
|
||||
* other in a way that survives a snapshot — they all root at `tenantId`).
|
||||
* handled here.
|
||||
*/
|
||||
import { defineCommand } from "citty";
|
||||
import consola from "consola";
|
||||
@@ -37,6 +34,7 @@ import {
|
||||
deserializeTenantManifest,
|
||||
type TenantSnapshotManifest,
|
||||
} from "./manifest.js";
|
||||
import { isTenantDerivedModel } from "./derived-models.js";
|
||||
import { decryptFile, type EncryptionConfig } from "../backup/encryption.js";
|
||||
|
||||
export interface PrismaRestoreRunner {
|
||||
@@ -206,7 +204,9 @@ export async function runTenantRestore(opts: RunRestoreOptions): Promise<RunRest
|
||||
for (const entry of manifest.models) {
|
||||
const filePath = join(stageDir, entry.path);
|
||||
const rows = await readJsonl(filePath);
|
||||
const remapped = rows.map((row) => ({ ...row, tenantId: opts.tenantId }));
|
||||
const remapped = isTenantDerivedModel(entry.model)
|
||||
? rows
|
||||
: rows.map((row) => ({ ...row, tenantId: opts.tenantId }));
|
||||
const result = await opts.prisma.createMany(entry.model, remapped);
|
||||
perModel.push({ model: entry.model, written: result.written, expected: entry.rowCount });
|
||||
if (result.written !== entry.rowCount) {
|
||||
|
||||
Reference in new issue
Block a user