Skip to content

Instantly share code, notes, and snippets.

@curtismckee
Last active July 5, 2018 17:58
Show Gist options
  • Save curtismckee/09f7964bd39f2a1f540ce2b76a709523 to your computer and use it in GitHub Desktop.
Save curtismckee/09f7964bd39f2a1f540ce2b76a709523 to your computer and use it in GitHub Desktop.
postgresql init example file
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