WIP Multi-tenant architecture.

This commit is contained in:
Ahmed Bouhuolia
2020-04-21 22:47:27 +02:00
parent 4e0d3feebe
commit 8f588ffc51
64 changed files with 812 additions and 447 deletions

View File

@@ -1,6 +1,6 @@
import Knex from 'knex';
import { knexSnakeCaseMappers } from 'objection';
import knexfile from '@/../knexfile';
import knexfile from '@/../config/systemKnexfile';
const config = knexfile[process.env.NODE_ENV];
const knex = Knex({

View File

@@ -1,16 +1,19 @@
import knexManager from 'knex-db-manager';
import knexfile from '@/../knexfile';
import knexfile from '@/../config/systemKnexfile';
import config from '@/../config/config';
const config = knexfile[process.env.NODE_ENV];
const knexConfig = knexfile[process.env.NODE_ENV];
console.log({
superUser: config.manager.superUser,
superPassword: config.manager.superPassword,
});
const dbManager = knexManager.databaseManagerFactory({
knex: config,
knex: knexConfig,
dbManager: {
// db manager related configuration
collate: [],
superUser: 'root',
superPassword: 'root',
// populatePathPattern: 'data/**/*.js', // glob format for searching seeds
superUser: config.manager.superUser,
superPassword: config.manager.superPassword,
},
});

View File

@@ -12,10 +12,6 @@ exports.up = function (knex) {
table.string('language');
table.date('last_login_at');
table.timestamps();
}).then(() => {
knex.seed.run({
specific: 'seed_users.js',
})
});
};

View File

@@ -0,0 +1,7 @@
import { Model } from 'objection';
import knex from '@/database/knex';
// Bind all Models to a knex instance. If you only have one database in
// your server this is all you have to do. For multi database systems, see
// the Model.bindKnex() method.
Model.knex(knex);