Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List applied sequelize migrations

Is there a way to show the migrations already applied ?

I would like to know which migration is the last one, so I can decide whether to undo it or not.

like image 963
FlyingPumba Avatar asked Oct 21 '25 12:10

FlyingPumba


2 Answers

You can use the helper method as mentioned by @mcranston18. In addition you can also pass an env variable as well to select the database you want to query.

NODE_ENV=test ./node_modules/.bin/sequelize db:migrate:status

which will give you an output like this

enter image description here Up means that the migration has run against the current database and down means it hasn't.

The default env would be picked from your Sequelize/index.js

This data is maintained by Sequelize in a table called SequelizeMeta. You can also query this table directly to know what was the last successful migration.

enter image description here

like image 187
AbhinavD Avatar answered Oct 23 '25 02:10

AbhinavD


npx sequelize db:migrate:status

works fine for me (Sequelize 6)

like image 25
Hop hop Avatar answered Oct 23 '25 01:10

Hop hop