0

I'm using sequelize-cli, and generating migrations but we have to add the definitions and constraints manually even though we have already defined all of that in the model file.

I've worked in django-rest-framework and just the command

python manage.py createmigrations

checks all the apps and their models and creates migrations for each model with all the fields, their attributes and constraints and all the additions or deletion or updates to the model

Wondering if we can do that with sequelize-cli for nodejs

NOTE: Need a new migration file for each model just like in python ( dhango-rest-framework) with a timestamp
( Python doesn't have timestamp )

PS: Tried Using "sequelize-mig" but it creates one file

1 Answers1

0

If I've understood your question correctly:

As I know, there is no official way to create some migrations based on the models you've already created. But if you use

sequelize model:create --name <name-of-your-model> --attributes <(for example) name:string, phone:bigint>

It'll make a model and its migration file along with the attributes you've provided. At least, it makes your job easier.

Besides that, I saw a tool called 'sequelize-auto-migrations' in the link below but I've never used it. I think it is worth checking. How to auto generate migrations with Sequelize CLI from Sequelize models?

[Anyway, be careful if you're going to use any of the items above in production]

I hope my answer helps you!