-- +goose Up
CREATE TABLE IF NOT EXISTS users (
    id serial NOT NULL,
    username VARCHAR(70) UNIQUE NOT NULL CHECK (length(username) != 0 AND username = lower(username)),
    hashed_password BYTEA NOT NULL CHECK (length(hashed_password) != 0),
    email VARCHAR(70) UNIQUE CHECK (length(email) != 0 AND email = lower(email)),
    expires_at TIMESTAMP NOT NULL,
    created_at TIMESTAMP NOT NULL,
    role INT NOT NULL CHECK (role BETWEEN 0 AND 3),
    PRIMARY KEY (id)
);

CREATE INDEX ON users (id);

CREATE INDEX ON users (username);

CREATE INDEX ON users (email);

-- +goose Down
DROP TABLE IF EXISTS users;