-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.sql
More file actions
92 lines (71 loc) · 2.25 KB
/
Copy pathdata.sql
File metadata and controls
92 lines (71 loc) · 2.25 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
DROP DATABASE IF EXISTS "jobly";
CREATE DATABASE "jobly";
\c "jobly"
CREATE TABLE companies(
handle TEXT PRIMARY KEY,
name TEXT UNIQUE NOT NULL,
num_employees INTEGER,
description TEXT,
logo_url TEXT
);
CREATE TABLE users(
username TEXT PRIMARY KEY,
password TEXT NOT NULL,
first_name TEXT,
last_name TEXT,
email TEXT,
photo_url TEXT,
is_admin BOOLEAN NOT NULL default FALSE
);
CREATE TABLE jobs(
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
salary FLOAT,
equity FLOAT CHECK(equity <= 1.0),
company_handle TEXT NOT NULL REFERENCES companies ON DELETE CASCADE,
date_posted timestamp NOT NULL DEFAULT NOW()
);
CREATE TABLE applications(
username TEXT NOT NULL REFERENCES users ON DELETE CASCADE,
job_id INTEGER REFERENCES jobs ON DELETE CASCADE,
state TEXT,
created_at TIMESTAMP DEFAULT current_timestamp,
PRIMARY KEY(username, job_id)
);
INSERT INTO companies (handle, name, num_employees, description, logo_url) VALUES
('testHandle', 'testName', 20, 'testing company','http://google.com'),
('apple', 'apple', 10000, 'a big company','http://google.com');
INSERT INTO users (username, password, first_name, last_name, email, photo_url) VALUES
('mcTestUsername', 'test1234', 'test', 'testLastName', 'test@test.com', 'http:google.com'),
('maragreene', 'password1', 'mara', 'greene', 'mgreene@skidmore.edu', 'http:google.com');
INSERT INTO jobs (title, salary, equity, company_handle) VALUES
('ceo', 1000000, 0.3, 'testHandle'),
('boss',100000, 0.4,'apple');
Create test database with tables
DROP DATABASE IF EXISTS "jobly-test";
CREATE DATABASE "jobly-test";
\c "jobly-test"
CREATE TABLE companies(
handle TEXT PRIMARY KEY,
name TEXT UNIQUE NOT NULL,
num_employees INTEGER,
description TEXT,
logo_url TEXT
);
CREATE TABLE users(
username TEXT PRIMARY KEY,
password TEXT NOT NULL,
first_name TEXT,
last_name TEXT,
email TEXT,
photo_url TEXT,
is_admin BOOLEAN NOT NULL default FALSE
);
CREATE TABLE jobs(
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
salary FLOAT,
equity FLOAT CHECK(equity <= 1.0),
company_handle TEXT NOT NULL REFERENCES companies ON DELETE CASCADE,
date_posted timestamp NOT NULL DEFAULT NOW()
);