-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigration.js
35 lines (29 loc) · 980 Bytes
/
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
const sqlite3 = require("sqlite3");
const db = new sqlite3.Database("./database.sqlite");
db.serialize(() => {
db.run(`DROP TABLE IF EXISTS Artist`);
db.run(`CREATE TABLE IF NOT EXISTS Artist (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
date_of_birth TEXT NOT NULL,
biography TEXT NOT NULL,
is_currently_employed INTEGER NOT NULL DEFAULT 1
)`);
db.run(`DROP TABLE IF EXISTS Series`);
db.run(`CREATE TABLE IF NOT EXISTS Series (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
description TEXT NOT NULL
)`);
db.run(`DROP TABLE IF EXISTS Issue`);
db.run(`CREATE TABLE IF NOT EXISTS Issue (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
issue_number INTEGER NOT NULL,
publication_date TEXT NOT NULL,
artist_id INTEGER NOT NULL,
series_id INTEGER NOT NULL,
FOREIGN KEY(artist_id) REFERENCES Artist(id),
FOREIGN KEY(series_id) REFERENCES Series(id)
)`);
});