user1031149
user1031149

Reputation: 41

Why aren't my tables being altered when I run sequelize.sync()?

When I run sequelize.sync(), it can create tables, but it doesn't alter existing ones, making it really difficult for development when I have to delete the tables every single time I want to make a change to the database.

Do I have to use migrations for development or is there a better way to do this?

Upvotes: 0

Views: 702

Answers (1)

meyer9
meyer9

Reputation: 1140

For development, there is now an option to sync the current tables by altering their structure. Using the latest version from the sequelize github repo, you can now run sync with the alter parameter.

Table.sync({alter: true})

This will alter the table to fit into the new models, but please note that this may cause some data to be deleted if you are removing or changing columns.

Upvotes: 3

Related Questions