chore(): Accept an extra agument 'all-or-nothing' on the migrate command (#14262)

* chore(): Accept an extra agument 'all-or-nothing' on the migrate command

* Create rich-camels-brush.md

* chore(): Accept an extra agument 'all-or-nothing' on the migrate command

* chore(): Accept an extra agument 'all-or-nothing' on the migrate command

* chore(): Accept an extra agument 'all-or-nothing' on the migrate command

* chore(): fix broken down migrations

* chore(): update changeset
This commit is contained in:
Adrien de Peretti
2025-12-10 09:23:41 +01:00
committed by GitHub
parent 9bcfb990bf
commit 356283c359
13 changed files with 139 additions and 56 deletions
@@ -23,10 +23,11 @@ export function buildRevertMigrationScript({ moduleName, pathToMigrations }) {
return async function ({
options,
logger,
migrationNames,
}: Pick<
LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions>,
"options" | "logger"
> = {}) {
> & { migrationNames?: string[] }) {
logger ??= console as unknown as Logger
logger.info(new Array(TERMINAL_SIZE).join("-"))
@@ -48,7 +49,10 @@ export function buildRevertMigrationScript({ moduleName, pathToMigrations }) {
})
try {
const result = await migrations.revert()
const revertOptions = migrationNames?.length
? { step: migrationNames.length }
: undefined
const result = await migrations.revert(revertOptions as any)
if (result.length) {
logger.info("Reverted successfully")
} else {
@@ -51,6 +51,7 @@ export function buildMigrationScript({ moduleName, pathToMigrations }) {
} else {
logger.info(`Skipped. Database is up-to-date for module.`)
}
return result
} catch (error) {
logger.error(`Failed with error ${error.message}`, error)
throw new MedusaError(MedusaError.Types.DB_ERROR, error.message)