import createDbFromSchema from "@/package-shared/shell/createDbFromSchema"; import mysql, { ServerlessMysql } from "serverless-mysql"; console.log(`Initializing Database ...`); /** * # Declare Global Variables */ declare global { var DB_CONN: ServerlessMysql; var DSQL_DB_CONN: ServerlessMysql; } global.DSQL_DB_CONN = mysql({ config: { host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, database: process.env.DSQL_DB_NAME, charset: "utf8mb4", // ssl: grabDbSSL(), }, }); global.DSQL_READ_ONLY_DB_CONN = mysql({ config: { host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_READ_ONLY_USERNAME, password: process.env.DSQL_DB_READ_ONLY_PASSWORD, port: process.env.DSQL_DB_PORT ? Number(process.env.DSQL_DB_PORT) : undefined, charset: "utf8mb4", // ssl: grabDbSSL(), }, }); global.DSQL_FULL_ACCESS_DB_CONN = mysql({ config: { host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_FULL_ACCESS_USERNAME, password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD, port: process.env.DSQL_DB_PORT ? Number(process.env.DSQL_DB_PORT) : undefined, charset: "utf8mb4", // ssl: grabDbSSL(), }, }); /** * # Run Function */ await createDbFromSchema({}); process.exit(0);