CREATE TABLE tenant_members (
    tenant_id TEXT NOT NULL REFERENCES tenants(id),
    user_id   TEXT NOT NULL REFERENCES users(id),
    status    TEXT NOT NULL DEFAULT 'invited' CHECK (status IN ('invited', 'active')),
    PRIMARY KEY (tenant_id, user_id)
);

CREATE INDEX idx_tenant_members_user ON tenant_members (user_id);
