ff-admin-server/src/data-source.ts

43 lines
1.6 KiB
TypeScript
Raw Normal View History

import "dotenv/config";
import "reflect-metadata";
import { DataSource } from "typeorm";
2024-08-26 15:00:23 +00:00
import { DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_TYPE } from "./env.defaults";
2024-08-25 11:36:19 +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-27 15:54:59 +00:00
import { userPermission } from "./entity/user_permission";
2024-08-25 11:36:19 +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";
import { Permissions1724661484664 } from "./migrations/1724661484664-permissions";
2024-08-27 15:54:59 +00:00
import { role } from "./entity/role";
import { rolePermission } from "./entity/role_permission";
import { RolePermission1724771491085 } from "./migrations/1724771491085-role_permission";
const dataSource = new DataSource({
2024-08-26 15:00:23 +00:00
type: DB_TYPE as any,
host: process.env.NODE_ENV || process.env.DBMODE ? "localhost" : DB_HOST,
port: 3306,
username: DB_USERNAME,
password: DB_PASSWORD,
database: DB_NAME,
synchronize: false,
logging: process.env.NODE_ENV ? true : ["schema", "error", "warn", "log", "migration"],
bigNumberStrings: false,
2024-08-27 15:54:59 +00:00
entities: [user, refresh, invite, userPermission, role, rolePermission],
migrations: [
Initial1724317398939,
RefreshPrimaryChange1724573307851,
Invite1724579024939,
Permissions1724661484664,
RolePermission1724771491085,
],
migrationsRun: true,
migrationsTransactionMode: "each",
subscribers: [],
});
export { dataSource };