Skip to main content

ClickHouse Schema

ClickHouse is the read-only analytics database. Data is synced by n8n workflows from Jira, Tempo, and the CDM pipeline. Never write to ClickHouse from the invoice application.

Actual Table Names

The table names below are the actual names in the ClickHouse cluster, which may differ from names in early specification documents. Always use these names in queries.

Connection

Endpoint: clickhouse-api.prxm.uz:443
Protocol: HTTPS (clickhouse.HTTP)
Database: default
TLS: Required

Tables

cdm.jira_applications

Client deals/contracts. Each application represents a service agreement with a client.

ColumnTypeDescription
application_keyStringPK — Unique application identifier
customer_keyStringForeign key to jira_customers
statusStringActive, Closed, etc.
application_nameStringHuman-readable name
descriptionStringApplication description
start_dateDateContract start
finish_dateNullable(Date)Contract end
deal_amountDecimal(18,2)Contract value (usually UZS)
deal_typeStringSUP, HR, or FP
monthly_limitNullable(UInt32)Hours included in SUP base
hourly_rateDecimal(18,2)Rate per hour
currencyStringUZS, USD, EUR
invoice_amountDecimal(18,2)International billing amount
agreement_dateNullable(Date)Agreement signing date
agreement_numberNullable(String)Agreement reference number
labelsStringProject labels (maps to worklogs)

Key gotchas:

  • monthly_limit is Nullable(UInt32) — use ifNull(monthly_limit, 0) or toFloat64() in queries
  • labels field may be empty for newer applications
  • labels maps to project_label in worklogs and issues

cdm.jira_customers

Client company details for invoice templates and international detection.

ColumnTypeDescription
customer_keyStringPK — Unique customer identifier
company_nameStringLegal company name
company_typeStringLLC, JSC, etc.
addressStringCompany address
tinStringTax ID (INN)
cceaStringОКОНХ code
swift_bicStringSWIFT/BIC code (international detection)
account_numberStringBank account number
bank_nameStringBank name
signer_full_nameStringAuthorized signer name
signer_titleStringSigner's position
vatStringVAT number
binStringBIN number
registration_numberStringRegistration number
countryStringCountry code
emailStringContact email
phoneStringContact phone
telegram_linkStringTelegram contact
websiteStringCompany website
sourceStringData source
customer_typeStringCustomer classification
industryStringIndustry sector

International detection: swift_bic.length > 2 or currency != 'UZS'


cdm.jira_contacts

Client contact persons (for email delivery in Phase 4).

ColumnTypeDescription
customer_keyStringFK to jira_customers
nameStringContact name
emailStringContact email
phoneStringContact phone

tempo.worklogs_flat

Time tracking entries from Tempo, synced every ~15 minutes.

ColumnTypeDescription
duration_secondsUInt32Time logged in seconds
account_idStringJira user account ID
user_nameStringDisplay name
start_dateDateDate work was performed
project_labelStringProject label (maps to application)
issue_keyStringJira issue key

Key gotchas:

  • Table is tempo.worklogs_flat (NOT tempo.worklogs)
  • duration_seconds is UInt32 — must scan into Go uint32
  • project_label maps to labels in cdm.jira_applications

jira.jira_issues

Jira issue metadata, used for categorization (issue type, priority).

ColumnTypeDescription
issue_keyStringJira issue key (e.g., PROJ-123)
issue_typeStringBug, Task, Story, Incident, Meeting, etc.
priorityStringP1, P2, P3, P4, P5
project_labelStringProject label
summaryStringIssue summary/title
customfield_10150StringCustom description field

Key gotchas:

  • Table is jira.jira_issues (NOT jira.issues)
  • Issue type and priority are used for rate tier assignment
  • Critical incident = issue_type = 'Incident' AND priority IN ('P1', 'P2', 'P3')

Application → Worklog Mapping

The connection between applications and worklogs goes through project labels:

One application can have multiple comma-separated labels, mapping to multiple projects in Jira.

Type Scanning in HTTP Mode

ClickHouse's HTTP protocol has strict type scanning:

ClickHouse TypeGo TypeNotes
UInt32uint32int will fail
Nullable(UInt32)*uint32 or use ifNull()Wrap in query
Decimal(18,2)float64 via toFloat64()Cast in query
StringstringDirect scan
Datetime.TimeDirect scan