migrateTable
uses tcmts.studio.editableCodebase, which uses tcmts.share.servedCodebase, which uses process
Bring a table's rows stored as an older row type up to its current one, as tcm data migrate <table> does (it's
run, so the table's migrate does it): what it said.
import { dataTables } from "#codebase/tcmts/cli/data_pages"; import { HttpError } from "#codebase/tcmts/server"; import { editableCodebase, runTcm } from "#codebase/tcmts/studio"; export async function migrateTable(table: string): Promise<string> { const cb = editableCodebase(); if (!dataTables(cb).some((t) => t.table === table)) throw new HttpError(404, `There's no table ${table}.`); const out = await runTcm(cb.lay.root, ["data", "migrate", table], { branch: true }); if (out.code !== 0) throw new HttpError( 400, out.text.split("\n").slice(0, 8).join("\n") || `tcm data migrate ${table} failed`, ); return out.text.split("\n")[0] || `Migrated ${table}.`; }
uses
- tcmts.cli.data_pages.dataTables
- tcmts.server.HttpError
- tcmts.studio.editableCodebase
- tcmts.studio.runTcm