Reputation: 47
This is my first time making a postgre database on Sequelize, and I can't figure out the migrations. As far as I understand, you have to change the database with migrations only, and you can get data through the model (probably this is not true). I want to create a RESTAPI, and I confused, how should I add/change/delete columns - through migrations or through a model? If through migrations, then I need to use the CLI for them to work, but I have no idea how to call db:migrate from express. The documentation says that all changes to the database must be done through migrations. I can not figure out what is the advantage of migrations and how to interact from the database during the execution of the server application. Thanks for answer
Upvotes: 0
Views: 171
Reputation: 110
Changing columns is different from changing rows. I think you are referring to changing rows here. Columns refer to the properties of records while rows refer to the actual records themselves.
Migrations are typically used for changing the schema definition of tables that have already been defined (which includes but not limited to changing columns).
This may include
Examples would be:
If you are actually talking about updating rows, deleting rows, and in general, querying for data, refer to Sequelize querying basics to understand more.
Upvotes: 1