Skip to content

Run migrations in a multy tenancy environment #401

Answered by mario-lemes
mario-lemes asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @mmkal,

Your response came at the perfect timing, I was playing around with the SequelizeStorage in order to have PR candidate that cover the use case we have been discussing and I realized a very crucial thing. The SequelizeStorage constructors allow passing the model object itself! That changes all. I can simply define the "SequelizeMeta" model for each tenant on runtime and pass it to the SequelizeStorage constructor. It worked like a charm, this is the code example:


async migrate(schema) {
      const databaseLogger = Loggers.newLogger('database');
      // Migrations model
      const model = sequelize.define(
        'MigrationsMeta',
        {
          name: {
            typ…

Replies: 11 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mmkal
Comment options

Comment options

You must be logged in to vote
5 replies
@mmkal
Comment options

@mario-lemes
Comment options

@mmkal
Comment options

@mario-lemes
Comment options

@mmkal
Comment options

Answer selected by mario-lemes
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #401 on November 29, 2020 20:07.