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