feat(cli): add --no-execution option to the "up" command

...which can be used to log manually run migrations as successful or for baselining a database.
This commit is contained in:
Joakim Carlstein 2024-01-19 13:13:33 +01:00 committed by Joakim Carlstein
parent e71c318ea5
commit f515c8a854
7 changed files with 138 additions and 18 deletions

View file

@ -72,6 +72,9 @@ const up: Action = async (args) => {
color: {
type: 'boolean',
},
'no-execution': {
type: 'boolean',
},
'no-color': {
type: 'boolean',
},
@ -100,6 +103,8 @@ Options:
--dry List the pending migrations that would be run without actually running them
--color Force color output (this option is passed to the reporter)
--no-color Disable color output (this option is passed to the reporter)
--no-execution Mark the migrations as executed and successful without actually running them,
which is useful if you want to mark migrations as successful after running them manually
Examples:
@ -109,6 +114,7 @@ Examples:
emigrate up -d ./migrations -s mysql --import dotenv/config
emigrate up --limit 1
emigrate up --to 20231122120529381_some_migration_file.js
emigrate up --to 20231122120529381_some_migration_file.js --no-execution
`;
if (values.help) {
@ -127,6 +133,7 @@ Examples:
to,
limit: limitString,
import: imports = [],
'no-execution': noExecution,
} = values;
const plugins = [...(config.plugins ?? []), ...(values.plugin ?? [])];
@ -153,6 +160,7 @@ Examples:
limit,
from,
to,
noExecution,
color: useColors(values),
});
} catch (error) {