update migration to before deployment in freight api

This commit is contained in:
yonastewabe
2026-07-24 14:01:21 +03:00
parent 278d7c333a
commit 16a7aebadd
6 changed files with 49 additions and 26 deletions

View File

@@ -1,21 +1,11 @@
// apps/edr-freight-api/src/data-source.ts
import 'dotenv/config';
import { DataSource } from 'typeorm';
//import { ensurePostgresSchemas } from './utils/ensure-postgres-schemas'; // adjust path if needed
import "dotenv/config";
import { DataSource, DataSourceOptions } from "typeorm";
import { buildDataSourceOptions } from "./config/database.config";
export const AppDataSource = new DataSource({
type: 'postgres',
host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT ?? 5433),
username: process.env.DB_USER ?? 'postgres',
password: process.env.DB_PASSWORD ?? '',
database: process.env.DB_NAME ?? 'edr_freight',
schema: 'freight', // default schema for entities without an explicit schema
entities: [__dirname + '/**/*.entity{.ts,.js}'],
migrations: [__dirname + '/migrations/*{.ts,.js}'],
synchronize: false,
logging: process.env.TYPEORM_LOGGING === 'true',
});
...buildDataSourceOptions(),
schema: "freight",
} as DataSourceOptions);
// Optional: call ensurePostgresSchemas before initializing
// But you can also run it separately.
export default AppDataSource;