-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathseed.js
66 lines (55 loc) · 2.92 KB
/
seed.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var express = require('express');
var pg = require('pg');
var connectionString = process.env.DATABASE_URL || 'postgres://localhost:5432/menyoudb';
var client = new pg.Client(connectionString);
client.connect(function (err) {
if (err) throw err;
client.query("CREATE TABLE \
categories( \
id SERIAL PRIMARY KEY, \
name VARCHAR(40) not null)");
client.query("CREATE TABLE \
menuitems( \
id SERIAL PRIMARY KEY, \
name VARCHAR(40) not null, \
description VARCHAR(40) not null, \
price NUMERIC(6,2) not null, \
category_id INTEGER REFERENCES categories(id))");
client.query("CREATE TABLE \
orders( \
id SERIAL PRIMARY KEY, \
customer VARCHAR(40) not null, \
totalprice NUMERIC(6,2) not null, \
complete boolean default false)");
client.query("CREATE TABLE \
suborders( \
id SERIAL PRIMARY KEY, \
description VARCHAR(40) not null, \
subtotalprice NUMERIC(6,2) not null, \
quantity INTEGER not null, \
id_orders INTEGER REFERENCES orders(id), \
id_menuitems INTEGER REFERENCES menuitems(id))");
client.query("INSERT INTO \
categories(name) \
VALUES('Breakfast'), \
('Lunch'), \
('Dinner'), \
('Desert'), \
('Drinks')");
client.query("INSERT INTO \
menuitems(name, description, price, category_id) \
VALUES('Walker Texas Brisket', 'Texas sized burger in walker sauce', 12.99, 3), \
('Roundhouse Kick Burger', 'Roundhouse kick to the gut', 12.99, 3), \
('The Delta Four-Cheese Pizza', 'Baked by Chuck staring at it for 1 min', 14.99, 3), \
('Kickin Grits and Taters', 'Grits and seasoned taters', 9.99, 1), \
('Magnus Stack', 'Large stack of pancakes', 9.99, 1), \
('Hearty Oats and Toast', 'Oatmeal served with toast', 9.99, 1)");
client.query("INSERT INTO \
menuitems(name, description, price, category_id) \
VALUES('Grilled Cheese Sandwich', 'Tasty grilled cheese sandwich', 7.99, 2), \
('Philly Cheese Sandwich', 'Philly cheese style sandwich', 12.99, 2), \
('Walker Kickin Chicken Salad', 'Grilled chicken salad', 9.99, 2), \
('Bucket O Oreos', 'Oreos with a tall glass of milk', 5.99, 3), \
('Red Bearded Velvet Cake', 'Red Velvelt Cake', 5.99, 3), \
('Mango Spritzer', 'Mango and orange juice in champagne', 7.99, 4)");
});