sequelize / sequelize-auto

Automatically generate bare sequelize models from your database.
2.9k stars 527 forks source link

The same Table name on different schemas on MSSQL #631

Open Morbraki opened 1 year ago

Morbraki commented 1 year ago

When using the sequelize-auto command to create the objects from the Databank and there's a Table name doubled in different schemas like dbo.dataStatus and example.dataStatus, the generator first creates the dbo one and then override it with the one from the cloud. So my Question is, if there is a way, to let the generator write the schema in the object name. So instead overriding dataSatus create for example dbo_dataStatus and cloud_dataStatus?

csbrown commented 1 year ago

I am not currently having this issue, but looked around because we do have lots of schemas and the possibility of overlap in the future is not vanishing.

Since there doesn't seem to be anything baked in, I suspect that you could roll-your-own with the --schema option, combined with the directory option, to auto-sequelize each schema individually into different model directories. Then you would have a DataStatus in /dist/models/dbo and a DataStatus in /dist/models/cloud. I haven't actually tried to implement this, but this seems viable.