feat(migration): old-LOI EOI recovery, folded berth-links, contactless flag
Three polish items so the legacy seed is one-shot and complete: - backfill-documents: recover the ~10 pre-Documenso "LOI process" EOIs whose signed PDF lives only as a NocoDB attachment in the `database` MinIO bucket (the pipeline keys EOI-doc creation off documensoID, so it never created rows for them). Reads EOI_Document attachment metadata from the local nocodb_legacy dump, pulls the PDF (read-only) from the `database` bucket, and CREATES the document + file + folder, linking the signed PDF. Idempotent via a `nocodb_eoi_document` ledger entry. - connect-berth-links: refactored into an exported connectBerthLinks() and folded into migrate-from-nocodb --apply (best-effort; skips with a warning if the local dump isn't restored) so the multi-berth junction is reconnected as part of the one-shot seed, not a separate manual step. - migration-apply: contactless legacy clients (no email/phone across the whole dedup cluster) get a per-port "Needs contact info" tag so staff can filter + chase them, instead of being dropped. The current dev DB's 29 contactless clients were tagged via a one-off mirroring the pipeline logic. EOI recovery code is ready but the actual run needs LEGACY_MINIO_* read creds supplied at the command line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -247,6 +247,27 @@ async function main(): Promise<void> {
|
||||
console.log(` … ${result.warnings.length - 20} more`);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Multi-berth links (folded in for the one-shot seed) ──────────────────
|
||||
// The dedup plan only carries each deal's single `Berth Number`; the legacy
|
||||
// `_nc_m2m_Berths_Interests` junction (multi-berth deals) is reconnected
|
||||
// here from the local `nocodb_legacy` snapshot. Best-effort: if the dump
|
||||
// isn't restored, log + continue (the standalone script can run it later).
|
||||
try {
|
||||
const { connectBerthLinks } = await import('./migration/connect-berth-links');
|
||||
const bl = await connectBerthLinks({ portSlug: port.slug });
|
||||
console.log(
|
||||
` Berths: ${bl.inserted} multi-berth links inserted (${bl.madePrimary} new primary), ${bl.skipped} already linked`,
|
||||
);
|
||||
if (bl.unresolved.length > 0) {
|
||||
console.log(` ⚠ ${bl.unresolved.length} moorings with no CRM berth`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(
|
||||
` Berths: ⚠ multi-berth link step skipped (${(err as Error).message}). ` +
|
||||
`Run scripts/migration/connect-berth-links.ts once the nocodb_legacy dump is restored.`,
|
||||
);
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user