Last active
July 5, 2018 17:58
-
-
Save curtismckee/09f7964bd39f2a1f540ce2b76a709523 to your computer and use it in GitHub Desktop.
postgresql init example file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER username WITH PASSWORD 'password'; | |
CREATE DATABASE database; | |
CREATE EXTENSION IF NOT EXIST "uuid-ossp"; | |
GRANT ALL PRIVILEGES ON DATABASE database to username; | |
CREATE TABLE IF NOT EXISTS users ( | |
id SERIAL PRIMARY KEY, | |
user_id uuid DEFAULT uuid_generate_v4(), | |
email VARCHAR NOT NULL, | |
name TEXT NOT NULL, | |
created_at DATE NOT NULL, | |
updated_at DATE NOT NULL | |
); | |
CREATE TABLE IF NOT EXISTS posts ( | |
id SERIAL PRIMARY KEY, | |
created_at DATE NOT NULL, | |
updated_at DATE NOT NULL, | |
users_id INT references USERS(id) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment