exodus-framework 2.1.1011 → 2.1.1012

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ declare class DatabaseService extends Service {
10
10
  onStartFail(): Promise<void>;
11
11
  private initConnection;
12
12
  createConnection(host: string, port: number, database: string, username: string, password: string, dialect: Dialect): Promise<Sequelize>;
13
- getConnection(tenantId: string): Promise<Sequelize>;
13
+ getConnection(tenantId: string, migrate?: boolean): Promise<Sequelize>;
14
14
  testConnection(data: {
15
15
  host: string;
16
16
  port: number;
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/services/database.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEnE,OAAO,EAAsB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAgB,SAAS,EAAE,MAAM,WAAW,CAAC;AAKpD,cAAM,eAAgB,SAAQ,OAAO;IACnC,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,WAAW,CAAyB;IAE/B,aAAa;IAWb,OAAO;IAqCP,WAAW;YAMV,cAAc;IA6Cf,gBAAgB,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO;IAwBL,aAAa,CAAC,QAAQ,EAAE,MAAM;IAO9B,cAAc,CAAC,IAAI,EAAE;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;KA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AO,EAAE,OAAO;IAwBL,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,UAAO;IAO9C,cAAc,CAAC,IAAI,EAAE;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;KAClB;YA2Ba,sBAAsB;IA6BvB,YAAY;IAKZ,aAAa;IAKb,oBAAoB,CAAC,QAAQ,EAAE,MAAM;YAMpC,UAAU;IASX,SAAS,CAAC,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,EAClD,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAU1B,OAAO,CAAC,qBAAqB;IAIhB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IA+BrC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAmBrC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAwBlC,kBAAkB,CAAC,UAAU,EAAE,SAAS;IAoBxC,gBAAgB,CAAC,UAAU,EAAE,SAAS;IAoBtC,kBAAkB;CAehC;AAED,eAAe,eAAe,CAAC"}
@@ -40,7 +40,7 @@ class DatabaseService extends _app.Service {
40
40
  const tenants = await this.getAllTenants();
41
41
  this.log(`⌚ Iniciando migração de ${tenants.length} tenants...`, 'warning');
42
42
  for (const tenant of tenants) {
43
- const sequelize = await this.getConnection(tenant.envUuid);
43
+ const sequelize = await this.getConnection(tenant.envUuid, false);
44
44
  if (sequelize) {
45
45
  this.log(`⌚ Executando migração no tenant ${tenant.envToken} | ${tenant.envUuid}`, 'warning');
46
46
  await this.execTenantMigrates(sequelize);
@@ -59,7 +59,7 @@ class DatabaseService extends _app.Service {
59
59
  }
60
60
 
61
61
  //* Connection
62
- async initConnection(tenantId) {
62
+ async initConnection(tenantId, migrate = true) {
63
63
  const tenantInfo = await this.getTenantInformation(tenantId);
64
64
  if (!tenantInfo) {
65
65
  throw new Error(`Não é possível inicia a conexão para o tenant ${tenantId}, a relação EnvDB não foi localizada`);
@@ -79,8 +79,10 @@ class DatabaseService extends _app.Service {
79
79
  }
80
80
  const password = data.payload;
81
81
  const connection = await this.createConnection(address, port, database, dbHost.username, password, dbHost.dialect);
82
- await this.execCoreMigrates(connection);
83
- await this.execTenantMigrates(connection);
82
+ if (migrate) {
83
+ await this.execCoreMigrates(connection); //para incluir recursos gerenciados pelo core para o tenant/service
84
+ await this.execTenantMigrates(connection);
85
+ }
84
86
  this.connections.set(tenantId, connection);
85
87
  this.log(`Conexão para o tenant ${tenantId} foi criada com sucesso`, 'success');
86
88
  }
@@ -107,9 +109,9 @@ class DatabaseService extends _app.Service {
107
109
  return null;
108
110
  }
109
111
  }
110
- async getConnection(tenantId) {
112
+ async getConnection(tenantId, migrate = true) {
111
113
  if (!this.connections.has(tenantId)) {
112
- await this.initConnection(tenantId);
114
+ await this.initConnection(tenantId, migrate);
113
115
  }
114
116
  return this.connections.get(tenantId);
115
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodus-framework",
3
- "version": "2.1.1011",
3
+ "version": "2.1.1012",
4
4
  "description": "Exodus Framework",
5
5
  "author": "jhownpaixao",
6
6
  "license": "ISC",