-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpostgres_table_create.sql
77 lines (74 loc) · 1.98 KB
/
postgres_table_create.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
--
--PostgreSQL database Creation
--
--Connects to env file
\i .env
--This file sets up the schema of our database, and will maintain the connection to the database across users
--
--To invoke this file, insert the below code in the terminal
--psql -d ${PG_URI} -f postgres_table_create.sql
--I did not set a port initially, but to do so you would add -p <port>
-- and instead of ${PG_URI} use your own URI
-------------------
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path','',false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET idleTimeoutMillis = 5000;
SET connectionTimeoutMillis = 7500;
--these last 2 items are in place to correct thr open handle issue
-------------------
-- CREATE EXTENSION pgcrypto;
-------------------
CREATE TABLE public.users (
_id serial NOT NULL,
full_name varchar NOT NULL,
user_name varchar NOT NULL UNIQUE,
email varchar NOT NULL UNIQUE,
password_ varchar NOT NULL,
${TEST_TOKEN} BOOLEAN DEFAULT false,
CONSTRAINT users_pk PRIMARY KEY ("_id")
) WITH (
OIDS=FALSE
);
-------------------
--
--Test DATA for users
-------------------
-- INSERT INTO public.users (full_name, user_name, email, password_) VALUES ('John Doe', 'JohnnyD', '[email protected]','jdpassword');
-------------------
--To clear Table, uncomment the below line, and remove the '/'
-- -- -- D/R/O/P T/A/B/L/E public.users
--
--To retrieve the information
--
-- SELECT _id
-- FROM users
-- WHERE email = '[email protected]'
-- AND password = crypt('jdpassword', password);
--
-- Expected Output
--
-- _id
-- ------
-- 1
-- (1 row)
--
-- Example of Bad Password
--
-- SELECT _id
-- FROM users
-- WHERE email = '[email protected]'
-- AND password = crypt('wrongpassword', password);
--
-- Expected Output
--
-- _id
-- ------
-- (0 rows)