@rws-framework/db 3.11.1 → 3.12.1

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.1",
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;
@@ -446,6 +447,23 @@ datasource db {
446
447
 
447
448
  const [_, schemaPath] = DbUtils.getProcessedSchemaDir();
448
449
 
449
- await rwsShell.runCommand(`${DbUtils.detectInstaller()} prisma db push --schema=${schemaPath}`, process.cwd());
450
+ const prismaPath = require.resolve('prisma/build/index.js');
451
+
452
+ // Set environment variables
453
+ const env = {
454
+ ...process.env,
455
+ [this.dbUrlVarName]: configService.get('db_url')
456
+ };
457
+
458
+ // Execute prisma db push programmatically
459
+ execSync(`node ${prismaPath} db push --schema=${schemaPath} --force-reset`, {
460
+ cwd: process.cwd(),
461
+ stdio: 'inherit',
462
+ env
463
+ });
464
+
465
+ // await rwsShell.runCommand(`${DbUtils.detectInstaller()} prisma db push --schema=${schemaPath}`, process.cwd(), false, { env: {
466
+ // PRISMA_DB_URL: configService.get('db_url')
467
+ // }});
450
468
  }
451
469
  }