aboutsummaryrefslogtreecommitdiff
path: root/scripts/setup_database.js
blob: 554f8d102059f71739728d459bf4475c5c0d4c52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';

const Config = require('../config/config');
const Mysql = require('mysql2');

const internals = {};

internals.run = () => {

  console.log('        .');
  console.log('       /');
  console.log('    +-----+');
  console.log('    | o o |  - Loading Good Things Momentarily');
  console.log('    +-----+');
  console.log('  +---------+');
  console.log(' /|    [][] |\\');
  console.log(' ||         | |');
  console.log(' ||         |  \\c');
  console.log(' ^+---------+');
  console.log('      (.) ');

  const connection = Mysql.createConnection(Config.mysql);

  console.log(`> *BEEP* CREATING TABLE: ${Config.mysql.tableName}!`);
  connection.query(`CREATE TABLE ${Config.mysql.tableName} (` +
                    'id SERIAL, ' +
                    'l VARCHAR(255), ' +
                    'g VARCHAR(255), ' +
                    't VARCHAR(255), ' +
                    'm VARCHAR(255), ' +
                    'emoji VARCHAR(255), ' +
                    'PRIMARY KEY (id) ' +
                    ') CHARACTER SET utf8mb4', (err) => {

    if (err) {
      console.error(`> *BWOOOP* ERROR DETECTED: ${err.message}!`);
      process.exit(1);
    }

    console.log('> *BEEP BEEP* SUCCESS!');
    process.exit(0);
  });
};

internals.run();