Skip to content

Commit

Permalink
fix(typeorm): update migration flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Sep 12, 2023
1 parent fdb2c74 commit 8fd7c36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { domifaConfig } from "../../../config";
import { isCronEnabled } from "../../../config/services/isCronEnabled.service";

export const EXECUTE_MIGRATIONS =
((domifaConfig().envId === "preprod" || domifaConfig().envId === "prod") &&
isCronEnabled()) ||
domifaConfig().envId === "local";
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import { PostgresConnectionOptions } from "typeorm/driver/postgres/PostgresConne
import { domifaConfig } from "../../../config";
import { appLogger } from "../../../util";
import { CustomTypeOrmLogger } from "../../../util/CustomTypeOrmLogger";
import { isCronEnabled } from "../../../config/services/isCronEnabled.service";

const isTypescriptMode = __filename.split(".").pop() === "ts"; // if current file extension is "ts": use src/*.ts files, eles use dist/*.js files
const executeMigrations =
((domifaConfig().envId === "preprod" || domifaConfig().envId === "prod") &&
isCronEnabled()) ||
domifaConfig().envId === "local";

let connectOptionsPaths: Pick<
PostgresConnectionOptions,
Expand Down Expand Up @@ -53,7 +48,7 @@ export const PG_CONNECT_OPTIONS: PostgresConnectionOptions = {
type: "postgres",
synchronize: false,
migrationsTransactionMode: "each",
migrationsRun: executeMigrations,
migrationsRun: true,
host: domifaConfig().postgres.host,
port: domifaConfig().postgres.port,
username: domifaConfig().postgres.username,
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/database/services/_postgres/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./appTypeormManager.service";
export * from "./EXECUTE_MIGRATIONS.const";
export * from "./PG_CONNECT_OPTIONS.const";
export * from "./PG_MIGRATION_CONFIG.const";
export * from "./pgRepository.service";
Expand Down

0 comments on commit 8fd7c36

Please sign in to comment.