@rws-framework/db 3.11.1 → 3.12.0

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.
@@ -11,6 +11,7 @@ const _model_1 = require("../../models/_model");
11
11
  const utils_1 = require("./utils");
12
12
  const type_converter_1 = require("./type-converter");
13
13
  const relation_manager_1 = require("./relation-manager");
14
+ const child_process_1 = require("child_process");
14
15
  const _EXECUTE_PRISMA_CMD = true;
15
16
  const _REMOVE_SCHEMA_FILE = true;
16
17
  /**
@@ -339,8 +340,23 @@ datasource db {
339
340
  */
340
341
  static async pushDBModels(configService, dbService, leaveFile = false) {
341
342
  process.env = { ...process.env, [this.dbUrlVarName]: configService.get('db_url') };
343
+ console.log({ env: process.env.PRISMA_DB_URL });
342
344
  const [_, schemaPath] = utils_1.DbUtils.getProcessedSchemaDir();
343
- await console_1.rwsShell.runCommand(`${utils_1.DbUtils.detectInstaller()} prisma db push --schema=${schemaPath}`, process.cwd());
345
+ const prismaPath = require.resolve('prisma/build/index.js');
346
+ // Set environment variables
347
+ const env = {
348
+ ...process.env,
349
+ [this.dbUrlVarName]: configService.get('db_url')
350
+ };
351
+ // Execute prisma db push programmatically
352
+ (0, child_process_1.execSync)(`node ${prismaPath} db push --schema=${schemaPath} --force-reset`, {
353
+ cwd: process.cwd(),
354
+ stdio: 'inherit',
355
+ env
356
+ });
357
+ // await rwsShell.runCommand(`${DbUtils.detectInstaller()} prisma db push --schema=${schemaPath}`, process.cwd(), false, { env: {
358
+ // PRISMA_DB_URL: configService.get('db_url')
359
+ // }});
344
360
  }
345
361
  }
346
362
  exports.SchemaGenerator = SchemaGenerator;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/db",
3
3
  "private": false,
4
- "version": "3.11.1",
4
+ "version": "3.12.0",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -14,6 +14,7 @@ import { TypeConverter } from './type-converter';
14
14
  import { RelationManager } from './relation-manager';
15
15
  import { ITrackerMetaOpts } from '../../decorators/TrackType';
16
16
  import { IDbOpts } from '../../models/interfaces/IDbOpts';
17
+ import { execSync } from 'child_process';
17
18
 
18
19
  const _EXECUTE_PRISMA_CMD = true;
19
20
  const _REMOVE_SCHEMA_FILE = true;
@@ -444,8 +445,27 @@ datasource db {
444
445
  static async pushDBModels(configService: IDbConfigHandler, dbService: DBService, leaveFile = false): Promise<void> {
445
446
  process.env = { ...process.env, [this.dbUrlVarName]: configService.get('db_url') };
446
447
 
448
+ console.log({ env: process.env.PRISMA_DB_URL });
449
+
447
450
  const [_, schemaPath] = DbUtils.getProcessedSchemaDir();
448
451
 
449
- await rwsShell.runCommand(`${DbUtils.detectInstaller()} prisma db push --schema=${schemaPath}`, process.cwd());
452
+ const prismaPath = require.resolve('prisma/build/index.js');
453
+
454
+ // Set environment variables
455
+ const env = {
456
+ ...process.env,
457
+ [this.dbUrlVarName]: configService.get('db_url')
458
+ };
459
+
460
+ // Execute prisma db push programmatically
461
+ execSync(`node ${prismaPath} db push --schema=${schemaPath} --force-reset`, {
462
+ cwd: process.cwd(),
463
+ stdio: 'inherit',
464
+ env
465
+ });
466
+
467
+ // await rwsShell.runCommand(`${DbUtils.detectInstaller()} prisma db push --schema=${schemaPath}`, process.cwd(), false, { env: {
468
+ // PRISMA_DB_URL: configService.get('db_url')
469
+ // }});
450
470
  }
451
471
  }