diff options
author | LarsVomMars | 2020-10-02 14:10:51 +0200 |
---|---|---|
committer | LarsVomMars | 2020-10-02 14:10:51 +0200 |
commit | e00547732bd9c701546cacaa98a073d50caa6ec4 (patch) | |
tree | db79b339a154abc0f81648a6fa713233ac5cd06d | |
parent | 6f0b965f3a1a14a959c1cde7fa2a31fb7beaf03f (diff) |
Super duper fixibus
-rw-r--r-- | db.js | 9 | ||||
-rw-r--r-- | tables.sql | 8 |
2 files changed, 7 insertions, 10 deletions
@@ -12,9 +12,6 @@ class DB { database: process.env.DBName, }); this.init(); - this.query("SELECT * FROM users LIMIT 1").then((res) => { - if (res.length === 0) this.initValues(); - }); } connect() { @@ -38,9 +35,9 @@ class DB { fs.readFile(__dirname + "/names.csv", "utf8", async (err, data) => { if (err) throw err; - await this.query("INSERT INTO types (name) VALUES ('teacher'), ('puipl')"); + await this.query("INSERT INTO types (name) VALUES ('teacher'), ('pupil')"); await this.query( - "INSERT INTO class (name) VALUES ('TGM13.1'), ('TGM13.2'), (TGTM13.1), (TGI13.1), (TGI13.2)" + "INSERT INTO class (name) VALUES ('TGM13.1'), ('TGM13.2'), ('TGTM13.1'), ('TGI13.1'), ('TGI13.2')" ); const classes = data.split("--"); @@ -61,7 +58,7 @@ class DB { if (middlename) username += middlename[0].toLowerCase(); username += names[0].toLowerCase().slice(0, 2); const pwd = nanoid.nanoid(8); - const password = await bcrypt.hash(pwd, 12); + const password = await bcrypt.hash(pwd, 10); userPasswords[classIndex].push({ username, pwd }); await this.query( "INSERT INTO users (username, name, middlename, surname, password, class_id, type_id) VALUE (?,?,?,?,?,?,?)", @@ -9,10 +9,10 @@ CREATE TABLE IF NOT EXISTS theme( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- TODO: Remove dropping --- DROP TABLE IF EXISTS quotes; --- DROP TABLE IF EXISTS users; --- DROP TABLE IF EXISTS types; --- DROP TABLE IF EXISTS class; +DROP TABLE IF EXISTS quotes; +DROP TABLE IF EXISTS users; +DROP TABLE IF EXISTS types; +DROP TABLE IF EXISTS class; CREATE TABLE IF NOT EXISTS types( id INTEGER PRIMARY KEY AUTO_INCREMENT, |