CREATE TABLE organizations (
  organization_id   VARCHAR(40)  PRIMARY KEY,
  name              VARCHAR(100) NOT NULL,
  slug              VARCHAR(50)  NOT NULL UNIQUE,
  plan_tier         VARCHAR(20)  NOT NULL DEFAULT 'free',
  max_agents        INTEGER      NOT NULL DEFAULT 100,
  max_tokens_per_month INTEGER   NOT NULL DEFAULT 10000,
  status            VARCHAR(20)  NOT NULL DEFAULT 'active',
  created_at        TIMESTAMPTZ  NOT NULL DEFAULT NOW(),
  updated_at        TIMESTAMPTZ  NOT NULL DEFAULT NOW(),
  CONSTRAINT organizations_status_check CHECK (status IN ('active', 'suspended', 'deleted')),
  CONSTRAINT organizations_plan_check CHECK (plan_tier IN ('free', 'pro', 'enterprise'))
);
CREATE INDEX idx_organizations_slug ON organizations(slug);
CREATE INDEX idx_organizations_status ON organizations(status);
