-
Notifications
You must be signed in to change notification settings - Fork 0
/
migration.js
36 lines (32 loc) · 1.34 KB
/
migration.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
const sqlite3 = require('sqlite3');
const db = new sqlite3.Database('./database.sqlite');
db.serialize(function() {
db.run('CREATE TABLE IF NOT EXISTS `Employee` ( ' +
'`id` INTEGER NOT NULL, ' +
'`name` TEXT NOT NULL, ' +
'`position` TEXT NOT NULL, ' +
'`wage` INTEGER NOT NULL, ' +
'`is_current_employee` INTEGER NOT NULL DEFAULT 1, ' +
'PRIMARY KEY(`id`) )');
db.run('CREATE TABLE IF NOT EXISTS `Timesheet` ( ' +
'`id` INTEGER NOT NULL, ' +
'`hours` INTEGER NOT NULL, ' +
'`rate` INTEGER NOT NULL, ' +
'`date` INTEGER NOT NULL, ' +
'`employee_id` INTEGER NOT NULL, ' +
'PRIMARY KEY(`id`), ' +
'FOREIGN KEY(`employee_id`) REFERENCES `Employee`(`id`) )');
db.run('CREATE TABLE IF NOT EXISTS `Menu` ( ' +
'`id` INTEGER NOT NULL, ' +
'`title` TEXT NOT NULL, ' +
'PRIMARY KEY(`id`) )');
db.run('CREATE TABLE IF NOT EXISTS `MenuItem` ( ' +
'`id` INTEGER NOT NULL, ' +
'`name` TEXT NOT NULL, ' +
'`description` TEXT, ' +
'`inventory` INTEGER NOT NULL, ' +
'`price` INTEGER NOT NULL, ' +
'`menu_id` INTEGER NOT NULL, ' +
'PRIMARY KEY(`id`), ' +
'FOREIGN KEY(`menu_id`) REFERENCES `Menu`(`id`) )');
});