Reputation: 1835
I have few microservices using Sequelize as an ORM. For simplicity I want all of then to share a single database even though they have nothing in common.
I need each microservice to have:
ms1_table1
, ms1_table2
I havn't found anything relevant in docs or Google. Any idea or package for that issue?
Upvotes: 0
Views: 1502
Reputation: 950
By default sequelize stores migration meta information in a table inside the same database. This is the primary road blocker for you.
You can prefer to use a different table name for each service
{
"development": {
"username": "root",
"password": null,
"database": "database_development",
"host": "127.0.0.1",
"dialect": "MySQL",
// Use a different table name. Default: SequelizeMeta
"migrationStorageTableName": "sequelize_meta",
// Use a different schema for the SequelizeMeta table
"migrationStorageTableSchema": "custom_schema"
}
}
This helps in having isolated migration acts for each microservice though all come in the same database
Upvotes: 0
Reputation: 109
Try to divide the single Db into multiple schemas (each for a Micro Service or so - it's also a good practice to start with this separation). Then, Sequelize has schema support (in constructor function you pass it in options.schema - default is 'public').
Try to look in sequelize documentation for further information about schema.
Does this solve your problem?
Upvotes: 0