I used the sequelize-automate library to generate models for MySQL/MariaDB database which is currently used by one of our projects. My aim was to get models from MySQL instance and create current tables for the MSSQL database as well. Briefly, I wanted to migrate definitions of tables and columns from MySQL to MSSQL.
Something went wrong during that process. Generated definitions (so SQL code) had had some invalidations.
SSMS fired an error when I just tried to execute the SQL code below generated by sequelize.sync() function.
Executing (default):
IF OBJECT_ID('[product_platforms]', 'U') IS NULL
CREATE TABLE [product_platforms] (
[id] INTEGER NOT NULL IDENTITY(1,1) DEFAULT NULL,
[product_id] INTEGER DEFAULT NULL,
PRIMARY KEY ([id]),
FOREIGN KEY ([product_id]) REFERENCES [product_model] ([id])
);
sequelize.js:1187
SequelizeDatabaseError: Could not create constraint or index. See previous errors.
Here is a list of the things that may cause similar errors above and thus people may not have a chance to import models to the desired database.
product_platforms table's identity column (auto-incremented) cannot have a default value (validation passes when I delete defaultValue prop in definition).
product_id foreign key belongs to a never exists table. The table it references to should have been product not product_model. There is a mismatch (validation passes when I delete _model suffix).
All of indexed tables have type: "BTREE" prop in their model definition files and cause SQL invalidations.
I used the
sequelize-automate
library to generate models forMySQL/MariaDB
database which is currently used by one of our projects. My aim was to get models from MySQL instance and create current tables for the MSSQL database as well. Briefly, I wanted to migrate definitions of tables and columns from MySQL to MSSQL.Something went wrong during that process. Generated definitions (so SQL code) had had some invalidations.
SSMS fired an error when I just tried to execute the SQL code below generated by sequelize.sync() function.
Here is a list of the things that may cause similar errors above and thus people may not have a chance to import models to the desired database.
product_platforms
table's identity column (auto-incremented) cannot have a default value (validation passes when I deletedefaultValue
prop in definition).product_id
foreign key belongs to a never exists table. The table it references to should have beenproduct
notproduct_model
. There is a mismatch (validation passes when I delete _model suffix).type: "BTREE"
prop in their model definition files and cause SQL invalidations.