83d8035dc2
* root + server * frontend * frontend-2 * dui3 * dui3 * tailwind theme * ui-components * preview service * viewer * viewer-sandbox * fileimport-service * webhook service * objectloader * shared * ui-components-nuxt * WIP full config * WIP full linter * eslint projectwide util * minor fix * removing redundant ci * clean up test errors * fixed prettier formatting * CI improvements * TSC lint fix * 'buildBatch' needs to be async since some batch types (like Text) require it. Removed a disabled liniting rule from ObjLoader * removed unnecessary void --------- Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
const knex = require('@/db/knex')
|
|
const { appRoot } = require('@/bootstrap')
|
|
const fs = require('fs/promises')
|
|
const { logger } = require('@/logging/logging')
|
|
|
|
/** @type {import('yargs').CommandModule} */
|
|
const command = {
|
|
command: 'create <name> [module]',
|
|
describe: 'Create a new migration',
|
|
builder(yargs) {
|
|
return yargs
|
|
.positional('name', {
|
|
describe: 'Migration name',
|
|
type: 'string'
|
|
})
|
|
.positional('module', {
|
|
describe: 'The server module into which this migration should be generated',
|
|
type: 'string',
|
|
default: 'core'
|
|
})
|
|
},
|
|
async handler(argv) {
|
|
const name = argv.name
|
|
const migrationDir = `${appRoot}/modules/${argv.module}/migrations`
|
|
|
|
try {
|
|
await fs.access(migrationDir)
|
|
} catch {
|
|
throw new Error(
|
|
`Migration directory '${migrationDir}' is not accessible! Check if it exists.`
|
|
)
|
|
}
|
|
|
|
logger.info('Creating migration...')
|
|
await knex.migrate.make(name, {
|
|
directory: migrationDir,
|
|
extension: 'ts'
|
|
})
|
|
logger.info('Creation done')
|
|
}
|
|
}
|
|
|
|
module.exports = command
|