DevLake Domain Model#
The domain model is DevLake's source-agnostic data layer β the normalized, tool-independent schema that all plugins write into after extracting and converting raw data. It lives under backend/core/models/domainlayer/ and is organized into six sub-packages :
| Package | Representative tables |
|---|---|
code/ | pull_requests, commits, refs, repos |
devops/ | cicd_pipelines, cicd_deployments, cicd_deployment_commits |
ticket/ | issues, incidents |
crossdomain/ | project_mapping, project_pr_metrics, project_incident_deployment_relationships |
codequality/ | cq_issues, cq_projects |
qa/ | qa_test_cases, qa_test_case_executions |
Base Structs and Embedding Hierarchy#
Every domain model struct embeds the same chain :
DomainEntity / DomainEntityExtended
βββ common.NoPKModel
βββ CreatedAt, UpdatedAt (time.Time)
βββ RawDataOrigin
βββ _raw_data_params (index for flushing stale records)
βββ _raw_data_table
βββ _raw_data_id
βββ _raw_data_remark
DomainEntityβ string primary key (Id) in the format<Plugin>:<Entity>:<PK0>:<PK1>β¦, enabling cross-plugin deduplication.DomainEntityExtendedβ same structure butvarchar(500)for longer IDs.NoPKModelβ embedsRawDataOrigin, which records the source raw table and row ID for each domain record (used for debugging and incremental sync).- Tool-layer models (plugin-private tables) embed
common.NoPKModelorcommon.Scopedirectly, without the string primary key.
DORA-Relevant Tables#
cicd_deployments#
CICDDeployment stores one row per deployment. Key fields:
Environment/OriginalEnvironmentβ normalized value (e.g.,PRODUCTION) and the raw label from the toolResult/Statusβ normalized outcome (SUCCESS,FAILURE) and run stateTaskDatesInfo(embedded) βCreatedDate,QueuedDate,StartedDate,FinishedDateDurationSec,QueuedDurationSec
cicd_deployment_commits#
CicdDeploymentCommit is the primary join between deployments and the commit graph. It carries all CICDDeployment fields plus:
CommitShaβ part of the composite primary key alongsideIdRepoId,RepoUrlβ links the deployment to a repositoryPrevSuccessDeploymentCommitIdβ populated by the DORA enricher to bound commit-diff ranges for Lead Time calculationToDeployment()helper converts a commit row back to aCICDDeployment
project_pr_metrics#
ProjectPrMetric stores per-PR lead-time decomposition. Composite primary key: Id + ProjectName.
| Field | Meaning |
|---|---|
PrCodingTime | First commit β PR creation (ms) |
PrPickupTime | PR creation β first review (ms) |
PrReviewTime | First review β PR merge (ms) |
PrDeployTime | PR merge β deployment finish (ms) |
PrCycleTime | Total end-to-end lead time (ms) |
DeploymentCommitId | FK to cicd_deployment_commits row that deployed this PR |
incidents#
Incident is populated from two upstream sources: issues tables and pull_requests (via PullRequest.ToIncident()) . Key DORA fields:
CreatedDate,ResolutionDateβ used for Mean Time to Restore (MTTR) calculationLeadTimeMinutesβ pre-computed durationTable+ScopeIdβ composite index that records the source table and scope
project_incident_deployment_relationships#
Links each incident to its nearest prior deployment within a project, enabling Change Failure Rate (CFR) calculation. See crossdomain/project_incident_deployment_relationship.go.
dora_benchmarks#
doraBenchmarkBasic (dora_benchmarks table) stores reference thresholds for rating teams against DORA report norms. Fields: Metric, Low, Medium, High, Elite, DoraReport. Seeded by the migration script with rows for both the 2021 and 2023 DORA reports. The 2023 report renamed "Time to restore service" β "Failed deployment recovery time" and tightened all thresholds .
Migrations#
Schema evolution for DORA-specific tables lives in backend/plugins/dora/models/migrationscripts/. Each migration file:
- Is named with a date prefix (e.g.,
20240223_add_dora_2023_benchmark.go) - Implements
Up(basicRes) error,Version() uint64, andName() string - Uses
migrationhelper.AutoMigrateTables()to run GORM'sAutoMigrateand record the run - Uses
archived.Model(numericID) for the in-migration struct definitions β distinct from the string-IDDomainEntityused at runtime
All migrations are registered in register.go.
Key Source Files#
| File | What it defines |
|---|---|
domainlayer/domainlayer.go | DomainEntity, DomainEntityExtended |
models/common/base.go | NoPKModel, RawDataOrigin, Scope, ScopeConfig |
devops/cicd_deployment.go | cicd_deployments table |
devops/cicd_deployment_commit.go | cicd_deployment_commits table |
crossdomain/project_pr_metric.go | project_pr_metrics table |
ticket/incident.go | incidents table |
20240223_add_dora_2023_benchmark.go | dora_benchmarks table + seed data |
| DevLake Domain Layer Schema (docs) | Full schema reference |