-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
36 lines (30 loc) · 1.09 KB
/
Copy pathinit.sql
File metadata and controls
36 lines (30 loc) · 1.09 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
-- Connect to Postgres.
-- psql -U goprojects
-- Create a user named `goprojects` with the password `goprojects`. If you ever
-- do this in production, please use a better password.
CREATE USER goprojects WITH PASSWORD 'goprojects';
-- Create the database we're going to use.
CREATE DATABASE goprojects;
-- Grant all privleges to our user on the DB.
GRANT ALL PRIVILEGES ON DATABASE goprojects to goprojects;
-- Create a new table to store our pages.
CREATE TABLE IF NOT EXISTS PAGES(
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
content TEXT NOT NULL
);
-- Create a new table to store our posts.
CREATE TABLE IF NOT EXISTS POSTS(
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
content TEXT NOT NULL,
date_created DATE NOT NULL
);
-- Create a new table to store our comments.
CREATE TABLE IF NOT EXISTS COMMENTS(
id SERIAL PRIMARY KEY,
author TEXT NOT NULL,
content TEXT NOT NULL,
date_created DATE NOT NULL,
post_id INT references POSTS(id)
);