-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 can't synchronize models which references other tables #11048
Comments
Does this only happen with postgres? Can you please check another dialect? |
Hello... I unfortunetly don't have the necessary resources to test it with other dialects... It can take me a while to have these resources... but for sure, it doesn't work with postgres dialect |
You can instantiate an in-memory SQLite instance as follows:
Can you please try it? |
yes, this is not an issue in sqlite 3 |
wait, i'm not sure sure that model.sync({alter:true}) in sqlite actually executes ALTER TABLE statements regardless, sqlite allows the REFERENCES clause in ALTER TABLE ALTER COLUMN, postgres sql does not, instead requiring something like ALTER TABLE ADD CONSTRAINT i'm facing the same issue currently |
https://www.sqlite.org/lang_altertable.html yea, sqllite doesn't support ALTER COLUMN, only DROP and ADD column |
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
What are you doing?
Trying to synchronize my defined Models with my sequelize instance
Code sample
User Model
To Reproduce
Steps to reproduce the behavior:
What do you expect to happen?
I expect sequelize to synchronize my defined models with my databasde
What is actually happening?
An error occurs while sequelize is trying to execute its generated sql instructions...
Here is the query Sequelize is trying to execute:
I tried to execute manually with pgAdmin the generated sql query and this is what I got:
In english, the translated error will be something like: "Syntax error near << REFERENCES >>
Environment
Dialect:
Dialect library version:
"pg": "7.11.0",
"pg-hstore": "2.3.3",
Database version: "PostgreSQL 9.4.4, compiled by Visual C++ build 1800, 64-bit"
Sequelize version: 5.8.7
Node Version: v10.10.0
OS: Windows 7 Professional SP1, 64 bits
If TypeScript related: TypeScript version: 3.5.1
The text was updated successfully, but these errors were encountered: