forked from paoyong/postgres-oauth-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psql_script.sql
53 lines (46 loc) · 1.3 KB
/
psql_script.sql
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
drop database if exists oauth_test;
create database oauth_test;
\connect oauth_test;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS facebook;
DROP TABLE IF EXISTS twitter;
DROP TABLE IF EXISTS google;
CREATE TABLE IF NOT EXISTS users (
id SERIAL,
username VARCHAR(100),
password VARCHAR(100),
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS facebook (
id SERIAL,
token TEXT NOT NULL,
facebook_id VARCHAR(100) UNIQUE,
email VARCHAR(100),
name VARCHAR(100),
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES users
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS twitter (
id SERIAL,
token VARCHAR(100) NOT NULL,
twitter_id VARCHAR(100) UNIQUE,
display_name VARCHAR(100),
username VARCHAR(100),
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES users
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS google (
id SERIAL,
token VARCHAR(100) NOT NULL,
google_id VARCHAR(100) UNIQUE,
email VARCHAR(100),
name VARCHAR(100),
PRIMARY KEY (id),
FOREIGN KEY (id) REFERENCES users
ON DELETE CASCADE
ON UPDATE CASCADE
);