CREATE TABLE IF NOT EXISTS invites ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), community_id uuid NOT NULL REFERENCES communities (id) ON DELETE CASCADE, created_by uuid REFERENCES users (id), code text UNIQUE NOT NULL, max_uses int, uses int DEFAULT 0, expires_at timestamptz, created_at timestamptz DEFAULT now() );