-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-source.ts
More file actions
33 lines (30 loc) · 1.35 KB
/
data-source.ts
File metadata and controls
33 lines (30 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import 'dotenv/config';
import { DataSource } from 'typeorm';
import configuration from './src/config/configuration';
import { Company } from './src/companies/entities/company.entity';
import { Clinic } from './src/clinics/clinic.entity';
import { User } from './src/users/entities/user.entity';
import { Patient } from './src/patients/patient.entity';
import { Service } from './src/services/service.entity';
import { Appointment } from './src/appointments/appointment.entity';
import { DoctorSchedule } from './src/scheduling/doctor-schedule.entity';
import { DoctorScheduleBreak } from './src/scheduling/doctor-schedule-break.entity';
const config = configuration();
/**
* TypeORM DataSource for CLI migrations
* Supports both DATABASE_URL and individual DB_* environment variables
*/
const dataSource = new DataSource({
type: 'postgres',
host: config.database.host,
port: config.database.port,
username: config.database.user,
password: config.database.password,
database: config.database.name,
entities: [Company, Clinic, User, Patient, Service, Appointment, DoctorSchedule, DoctorScheduleBreak],
migrations: ['src/database/migrations/*.ts'],
migrationsTableName: 'migrations',
// Important for production SSL connections (Render, etc.)
ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false,
});
export default dataSource;