-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
executable file
·43 lines (40 loc) · 1.23 KB
/
setup.js
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
const database = require("./settings");
const knex = require("knex")(database);
knex.schema
.hasTable("users")
.then(exists => {
if (!exists) {
return knex.schema
.createTable("users", table => {
table.increments("id");
table.string("name");
table.string("username");
table.string("password");
table.string("type").defaultTo("user");
})
.then(() => console.info("Users table created"))
.catch(error => console.error(error));
}
})
.catch(error => console.error(error));
knex.schema
.hasTable("tasks")
.then(exists => {
if (!exists) {
return knex.schema
.createTable("tasks", table => {
table.increments("id");
table.string("title");
table.string("details");
table.string("status").defaultTo("undone");
table.string("start_time");
table.string("end_time");
table.string("user_id");
table.string("created");
table.string("completed_on");
})
.then(() => console.info("task table created"))
.catch(error => console.error(error));
}
})
.catch(error => console.error(error));