CREATE TABLE users (
    id INTEGER PRIMARY KEY,
    points INTEGER NOT NULL DEFAULT 0 CHECK(points >= 0),
    referrer_id INTEGER REFERENCES users(id) CHECK(referrer_id != id),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE UNIQUE INDEX idx_users_id ON users(id);
