From d47b242cd1be4e08ed7c6b7bf61a65614541054c Mon Sep 17 00:00:00 2001 From: Kiril Yakymchuk Date: Sat, 31 Jan 2026 17:30:33 +0200 Subject: [PATCH 1/2] docs: skipping migration execution in Sequelize Added section on skipping migration execution with the --skip-execution flag, detailing its use cases and implications. --- .../version-6.x.x/other-topics/migrations.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/versioned_docs/version-6.x.x/other-topics/migrations.md b/versioned_docs/version-6.x.x/other-topics/migrations.md index e8c6a217e..99efd96ef 100644 --- a/versioned_docs/version-6.x.x/other-topics/migrations.md +++ b/versioned_docs/version-6.x.x/other-topics/migrations.md @@ -107,6 +107,32 @@ This command will execute these steps: - Start looking for any migration files which haven't run yet. This is possible by checking `SequelizeMeta` table. In this case it will run `XXXXXXXXXXXXXX-create-user.js` migration, which we created in last step. - Creates a table called `Users` with all columns as specified in its migration file. +## Skipping Migration Execution + +In some cases you may want to mark migrations as completed without actually executing their SQL. This can be useful when: + - The database schema was applied manually + - You are syncing migration history between environments + - You are adopting Sequelize CLI for an existing database + - You want to avoid re-running destructive or already-applied changes + +For this purpose, a custom `--skip-execution` flag is available. + +```text +npx sequelize-cli db:migrate --skip-execution +``` + +When this flag is provided, the migration process changes as follows: + - The CLI will still ensure that the SequelizeMeta table exists + - It will detect all pending migration files as usual + - Instead of running the migration up methods, it will: + - Record each pending migration as executed in the SequelizeMeta table + - Skip all database-altering SQL + +As a result, Sequelize considers these migrations as successfully applied, even though no schema changes were executed. + +**Important**: +Use `--skip-execution` with care. Since the actual migration logic is not run, the database schema must already match what the migrations expect. Otherwise, future migrations or application code may fail due to schema mismatches. + ## Undoing Migrations Now our table has been created and saved in the database. With migration you can revert to old state by just running a command. From db623cacc5897b587d181d60cae4afe6e915b475 Mon Sep 17 00:00:00 2001 From: Kiril Yakymchuk Date: Sat, 31 Jan 2026 17:38:41 +0200 Subject: [PATCH 2/2] docs: formatted markdown --- .../version-6.x.x/other-topics/migrations.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/versioned_docs/version-6.x.x/other-topics/migrations.md b/versioned_docs/version-6.x.x/other-topics/migrations.md index 99efd96ef..1c45d0345 100644 --- a/versioned_docs/version-6.x.x/other-topics/migrations.md +++ b/versioned_docs/version-6.x.x/other-topics/migrations.md @@ -109,11 +109,7 @@ This command will execute these steps: ## Skipping Migration Execution -In some cases you may want to mark migrations as completed without actually executing their SQL. This can be useful when: - - The database schema was applied manually - - You are syncing migration history between environments - - You are adopting Sequelize CLI for an existing database - - You want to avoid re-running destructive or already-applied changes +In some cases you may want to mark migrations as completed without actually executing their SQL. This can be useful when: - The database schema was applied manually - You are syncing migration history between environments - You are adopting Sequelize CLI for an existing database - You want to avoid re-running destructive or already-applied changes For this purpose, a custom `--skip-execution` flag is available. @@ -121,12 +117,7 @@ For this purpose, a custom `--skip-execution` flag is available. npx sequelize-cli db:migrate --skip-execution ``` -When this flag is provided, the migration process changes as follows: - - The CLI will still ensure that the SequelizeMeta table exists - - It will detect all pending migration files as usual - - Instead of running the migration up methods, it will: - - Record each pending migration as executed in the SequelizeMeta table - - Skip all database-altering SQL +When this flag is provided, the migration process changes as follows: - The CLI will still ensure that the SequelizeMeta table exists - It will detect all pending migration files as usual - Instead of running the migration up methods, it will: - Record each pending migration as executed in the SequelizeMeta table - Skip all database-altering SQL As a result, Sequelize considers these migrations as successfully applied, even though no schema changes were executed.