Skip to content

Latest commit

 

History

History
91 lines (78 loc) · 3.18 KB

File metadata and controls

91 lines (78 loc) · 3.18 KB

public.usage_records

Description

Columns

Name Type Default Nullable Children Parents Comment
id uuid uuid_generate_v4() false
org_id uuid false public.organizations
employee_id uuid true public.employees
resource_type varchar(50) false
quantity bigint false
cost_usd numeric(10,4) false
period_start timestamp without time zone false
period_end timestamp without time zone false
metadata jsonb '{}'::jsonb false
token_source varchar(20) 'company'::character varying true
created_at timestamp without time zone now() false

Constraints

Name Type Definition
usage_records_token_source_check CHECK CHECK (((token_source)::text = ANY ((ARRAY['company'::character varying, 'personal'::character varying])::text[])))
usage_records_org_id_fkey FOREIGN KEY FOREIGN KEY (org_id) REFERENCES organizations(id) ON DELETE CASCADE
usage_records_employee_id_fkey FOREIGN KEY FOREIGN KEY (employee_id) REFERENCES employees(id) ON DELETE SET NULL
usage_records_pkey PRIMARY KEY PRIMARY KEY (id)

Indexes

Name Definition
usage_records_pkey CREATE UNIQUE INDEX usage_records_pkey ON public.usage_records USING btree (id)
idx_usage_records_org_id CREATE INDEX idx_usage_records_org_id ON public.usage_records USING btree (org_id)
idx_usage_records_employee_id CREATE INDEX idx_usage_records_employee_id ON public.usage_records USING btree (employee_id)
idx_usage_records_period CREATE INDEX idx_usage_records_period ON public.usage_records USING btree (period_start, period_end)

Relations

erDiagram

"public.usage_records" }o--|| "public.organizations" : "FOREIGN KEY (org_id) REFERENCES organizations(id) ON DELETE CASCADE"
"public.usage_records" }o--o| "public.employees" : "FOREIGN KEY (employee_id) REFERENCES employees(id) ON DELETE SET NULL"

"public.usage_records" {
  uuid id
  uuid org_id FK
  uuid employee_id FK
  varchar_50_ resource_type
  bigint quantity
  numeric_10_4_ cost_usd
  timestamp_without_time_zone period_start
  timestamp_without_time_zone period_end
  jsonb metadata
  varchar_20_ token_source
  timestamp_without_time_zone created_at
}
"public.organizations" {
  uuid id
  varchar_255_ name
  varchar_100_ slug
  varchar_50_ plan
  jsonb settings
  integer max_employees
  text claude_api_token
  timestamp_without_time_zone created_at
  timestamp_without_time_zone updated_at
}
"public.employees" {
  uuid id
  uuid org_id FK
  uuid team_id FK
  uuid role_id FK
  varchar_255_ email
  varchar_255_ full_name
  varchar_255_ password_hash
  varchar_50_ status
  jsonb preferences
  text personal_claude_token
  timestamp_without_time_zone last_login_at
  timestamp_without_time_zone created_at
  timestamp_without_time_zone updated_at
  timestamp_without_time_zone deleted_at
}
Loading

Generated by tbls