BEGIN;
CREATE TABLE IF NOT EXISTS users (
    username text PRIMARY KEY,
    email text,
    password text,
    admin boolean
);

CREATE TABLE IF NOT EXISTS user_profiles (
    id SERIAL PRIMARY KEY,
    username text REFERENCES users (username),
    email text,
    location text,
    bio text
);

CREATE TABLE IF NOT EXISTS posts (
    id SERIAL PRIMARY KEY,
    title text,
    slug text,
    author text REFERENCES users (username),
    content text,
    time_published timestamp,
    modified bool,
    last_modified timestamp
);

CREATE TABLE IF NOT EXISTS tags (
    id SERIAL PRIMARY KEY,
    tag text,
    article_id int REFERENCES posts (id)
);

COMMIT;
