-- Add migration script here
CREATE TABLE access_codes (
    -- identifiers
    id SERIAL PRIMARY KEY,
    creator_id INTEGER NOT NULL REFERENCES users(id),

    -- code data
    code VARCHAR(255) NOT NULL,
    name VARCHAR(255) NOT NULL,

    -- uses
    uses INTEGER NOT NULL DEFAULT 0,
    max_uses INTEGER NOT NULL DEFAULT 1,

    -- time data
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    expires_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + INTERVAL '1 day'
);
