members-database/data-source.ts

47 lines
1.7 KiB
TypeScript

import "dotenv/config";
import "reflect-metadata";
import { DataSource } from "typeorm";
import { award } from "./entities/award";
import { communication } from "./entities/communication";
import { communicationType } from "./entities/communicationType";
import { executivePosition } from "./entities/executivePosition";
import { memberAwards } from "./entities/memberAwards";
import { memberExecutivePositions } from "./entities/memberExecutivePositions";
import { memberQualifications } from "./entities/memberQualifications";
import { member } from "./entities/member";
import { membership } from "./entities/membership";
import { membershipStatus } from "./entities/membershipStatus";
import { qualification } from "./entities/qualification";
import { Initial1724242210553 } from "./migrations/1724242210553-initial";
import { NamingAndCleanup1724396667634 } from "./migrations/1724396667634-namingAndCleanup";
const dataSource = new DataSource({
type: "mysql",
host: process.env.NODE_ENV || process.env.PKGMODE ? "localhost" : process.env.DB_HOST,
port: 3306,
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: "members",
synchronize: false,
logging: process.env.NODE_ENV ? true : ["schema", "error", "warn", "log", "migration"],
bigNumberStrings: false,
entities: [
award,
communication,
communicationType,
executivePosition,
memberAwards,
memberExecutivePositions,
memberQualifications,
member,
membership,
membershipStatus,
qualification,
],
migrations: [Initial1724242210553, NamingAndCleanup1724396667634],
migrationsRun: true,
migrationsTransactionMode: "each",
subscribers: [],
});
export { dataSource };