Files
speckle-server/packages/server/modules/cli/commands/db/migrate/latest.ts
T
Kristaps Fabians Geikins 4b06f42db7 chore(server): run TS files directly (no compilation) (#5134)
* sort of works

* type fixes

* added option to run old way too
2025-07-23 11:20:40 +02:00

24 lines
771 B
TypeScript

import { cliLogger as logger } from '@/observability/logging'
import type { CommonDbArgs } from '@/modules/cli/commands/db/helpers'
import { getTargettedDbClients } from '@/modules/cli/commands/db/helpers'
import type { CommandModule } from 'yargs'
const command: CommandModule<unknown, CommonDbArgs> = {
command: 'latest',
describe: 'Run all migrations that have not yet been run',
async handler(argv) {
logger.info('Running latest migrations on DB instances!')
const { regionKey } = argv
const dbs = await getTargettedDbClients({ regionKey })
for (const db of dbs) {
logger.info(`Running latest on DB ${db.regionKey}...`)
await db.client.migrate.latest()
}
logger.info('Completed running migration')
}
}
export = command