Use new dbClient import in the db init files

This commit is contained in:
Ean Milligan (Bastion) 2022-05-05 01:03:28 -04:00
parent 84768293c1
commit ce77893d37
3 changed files with 3 additions and 30 deletions

View File

@ -1,21 +1,8 @@
// This file will create all tables for the artificer schema // This file will create all tables for the artificer schema
// DATA WILL BE LOST IF DB ALREADY EXISTS, RUN AT OWN RISK // DATA WILL BE LOST IF DB ALREADY EXISTS, RUN AT OWN RISK
import {
// MySQL deps
Client
} from "../deps.ts";
import { LOCALMODE } from "../flags.ts";
import config from "../config.ts"; import config from "../config.ts";
import { dbClient } from "../src/db.ts";
// Log into the MySQL DB
const dbClient = await new Client().connect({
hostname: LOCALMODE ? config.db.localhost : config.db.host,
port: config.db.port,
username: config.db.username,
password: config.db.password,
});
console.log("Attempting to create DB"); console.log("Attempting to create DB");
await dbClient.execute(`CREATE SCHEMA IF NOT EXISTS ${config.db.name};`); await dbClient.execute(`CREATE SCHEMA IF NOT EXISTS ${config.db.name};`);

View File

@ -1,21 +1,7 @@
// This file will populate the tables with default values // This file will populate the tables with default values
import {
// MySQL deps
Client
} from "../deps.ts";
import { LOCALMODE } from "../flags.ts";
import config from "../config.ts"; import config from "../config.ts";
import { dbClient } from "../src/db.ts";
// Log into the MySQL DB
const dbClient = await new Client().connect({
hostname: LOCALMODE ? config.db.localhost : config.db.host,
port: config.db.port,
db: config.db.name,
username: config.db.username,
password: config.db.password,
});
console.log("Attempting to populate DB Admin API key"); console.log("Attempting to populate DB Admin API key");
await dbClient.execute("INSERT INTO all_keys(userid,apiKey) values(?,?)", [config.api.admin, config.api.adminKey]).catch(e => { await dbClient.execute("INSERT INTO all_keys(userid,apiKey) values(?,?)", [config.api.admin, config.api.adminKey]).catch(e => {

View File

@ -2,4 +2,4 @@ import { getModifiers } from "./getModifiers.ts";
export default { export default {
getModifiers getModifiers
}; };