2021-09-11 19:06:51 +03:00
|
|
|
const fs = require("fs");
|
|
|
|
const path = require("path");
|
2021-11-02 20:54:05 +02:00
|
|
|
const pkgUp = require("pkg-up");
|
2022-06-26 15:02:34 +03:00
|
|
|
const { backendDir } = require("./dist/backend/src/paths");
|
|
|
|
const { env } = require("./dist/backend/src/env");
|
2019-07-22 00:10:27 +03:00
|
|
|
|
2021-09-11 19:06:51 +03:00
|
|
|
const moment = require("moment-timezone");
|
|
|
|
moment.tz.setDefault("UTC");
|
2018-10-26 06:41:20 +03:00
|
|
|
|
2022-06-26 15:02:34 +03:00
|
|
|
const entities = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/data/entities/*.js"));
|
|
|
|
const migrations = path.relative(process.cwd(), path.resolve(backendDir, "dist/backend/src/migrations/*.js"));
|
|
|
|
const migrationsDir = path.relative(process.cwd(), path.resolve(backendDir, "src/migrations"));
|
2018-12-14 06:47:58 +02:00
|
|
|
|
2018-10-26 06:41:20 +03:00
|
|
|
module.exports = {
|
|
|
|
type: "mysql",
|
2022-06-26 15:02:34 +03:00
|
|
|
host: env.DB_HOST,
|
|
|
|
port: env.DB_PORT,
|
|
|
|
username: env.DB_USER,
|
|
|
|
password: env.DB_PASSWORD,
|
|
|
|
database: env.DB_DATABASE,
|
2021-09-11 19:06:51 +03:00
|
|
|
charset: "utf8mb4",
|
2018-10-26 06:41:20 +03:00
|
|
|
supportBigNumbers: true,
|
|
|
|
bigNumberStrings: true,
|
|
|
|
dateStrings: true,
|
|
|
|
synchronize: false,
|
2018-12-15 16:29:38 +02:00
|
|
|
connectTimeout: 2000,
|
2018-10-26 06:41:20 +03:00
|
|
|
|
2021-10-05 23:28:16 +03:00
|
|
|
logging: ["error", "warn"],
|
2021-09-12 21:47:03 +03:00
|
|
|
|
2018-10-26 06:41:20 +03:00
|
|
|
// Entities
|
2018-12-14 06:47:58 +02:00
|
|
|
entities: [entities],
|
2018-10-26 06:41:20 +03:00
|
|
|
|
|
|
|
// Pool options
|
|
|
|
extra: {
|
|
|
|
typeCast(field, next) {
|
2021-09-11 19:06:51 +03:00
|
|
|
if (field.type === "DATETIME") {
|
2018-10-26 06:41:20 +03:00
|
|
|
const val = field.string();
|
2021-09-11 19:06:51 +03:00
|
|
|
return val != null ? moment.utc(val).format("YYYY-MM-DD HH:mm:ss") : null;
|
2018-10-26 06:41:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return next();
|
2021-09-11 19:06:51 +03:00
|
|
|
},
|
2018-10-26 06:41:20 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// Migrations
|
2018-12-14 06:47:58 +02:00
|
|
|
migrations: [migrations],
|
2018-10-26 06:41:20 +03:00
|
|
|
cli: {
|
2019-11-30 23:38:11 +02:00
|
|
|
migrationsDir,
|
2018-10-26 06:41:20 +03:00
|
|
|
},
|
|
|
|
};
|