-- Database schema initialisation
-- Executed once on the first PostgreSQL startup in Docker

CREATE TABLE users (
    id         SERIAL PRIMARY KEY,
    username   VARCHAR(64) UNIQUE NOT NULL,
    password   TEXT NOT NULL,          -- bcrypt hash
    role       VARCHAR(16) NOT NULL DEFAULT 'user',  -- 'user' | 'admin'
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Index on username (frequently used during login)
CREATE INDEX idx_users_username ON users(username);
