New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sequelize.sync({ force: 'if-mismatch' })
#15187
Comments
Is it also possible to add new column |
What would be the use case for such a column? |
No specific use case, just did track when the tables is getting updated. |
Well |
I see, lets skip that I guess :D |
Feature Description
Describe the feature you'd like to see implemented
Having the possibility of setting the
force
option insequelize.sync
toif-mismatch
(orif-needed
?):sequelize.sync({ force: 'if-mismatch' }): Promise<boolean>
Describe why you would like this feature to be added to Sequelize
When modifying an existing model during development, none of the existing solutions work very well:
sequelize.sync()
does not update an existing table at allsequelize.sync({ alter: true })
will never be able to perfectly update an existing table, so we usually just don't use it at all. (for instance, it's impossible foralter
to add a non-null column that doesn't have a default value).sequelize.sync({ force: true })
+ seeding with dev data works, but it resets the database on every app restart which makes it inconvenient.So far I've always used
sequelize.sync({ force: true })
, but I comment it out when I don't need it.With something like
sequelize.sync({ force: 'if-mismatch' })
, we could fully reset the database, but only when one of the tables is outdated.In this design, I'm making that method return
true
when a synchronization happened. This boolean can then be used by user code to run dev data seeding accordingly.This would be a non-trivial feature. We'd need to rely on
describeTable
, which has many quirks. But in time we should be able to implement something like thisIs this feature dialect-specific?
Would you be willing to resolve this issue by submitting a Pull Request?
Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.
The text was updated successfully, but these errors were encountered: