2024-08-22 09:40:31 +00:00
|
|
|
import "dotenv/config";
|
|
|
|
import "reflect-metadata";
|
|
|
|
import { DataSource } from "typeorm";
|
2024-08-26 11:47:08 +00:00
|
|
|
import { DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME } from "./env.defaults";
|
2024-08-25 11:36:19 +00:00
|
|
|
|
2024-08-22 09:40:31 +00:00
|
|
|
import { user } from "./entity/user";
|
|
|
|
import { refresh } from "./entity/refresh";
|
2024-08-25 11:36:19 +00:00
|
|
|
import { invite } from "./entity/invite";
|
2024-08-26 11:47:08 +00:00
|
|
|
import { permission } from "./entity/permission";
|
2024-08-25 11:36:19 +00:00
|
|
|
|
2024-08-22 09:40:31 +00:00
|
|
|
import { Initial1724317398939 } from "./migrations/1724317398939-initial";
|
2024-08-25 08:09:57 +00:00
|
|
|
import { RefreshPrimaryChange1724573307851 } from "./migrations/1724573307851-refreshPrimaryChange";
|
2024-08-25 11:36:19 +00:00
|
|
|
import { Invite1724579024939 } from "./migrations/1724579024939-invite";
|
2024-08-26 11:47:08 +00:00
|
|
|
import { Permissions1724661484664 } from "./migrations/1724661484664-permissions";
|
2024-08-22 09:40:31 +00:00
|
|
|
|
|
|
|
const dataSource = new DataSource({
|
|
|
|
type: "mysql",
|
2024-08-25 16:07:34 +00:00
|
|
|
host: process.env.NODE_ENV || process.env.DBMODE ? "localhost" : DB_HOST,
|
2024-08-22 09:40:31 +00:00
|
|
|
port: 3306,
|
2024-08-25 16:07:34 +00:00
|
|
|
username: DB_USERNAME,
|
|
|
|
password: DB_PASSWORD,
|
|
|
|
database: DB_NAME,
|
2024-08-22 09:40:31 +00:00
|
|
|
synchronize: false,
|
|
|
|
logging: process.env.NODE_ENV ? true : ["schema", "error", "warn", "log", "migration"],
|
|
|
|
bigNumberStrings: false,
|
2024-08-26 11:47:08 +00:00
|
|
|
entities: [user, refresh, invite, permission],
|
|
|
|
migrations: [Initial1724317398939, RefreshPrimaryChange1724573307851, Invite1724579024939, Permissions1724661484664],
|
2024-08-22 09:40:31 +00:00
|
|
|
migrationsRun: true,
|
|
|
|
migrationsTransactionMode: "each",
|
|
|
|
subscribers: [],
|
|
|
|
});
|
|
|
|
|
|
|
|
export { dataSource };
|