Skip to content

DashboardService — DDL appendix

Generated from the architecture model

This page is rendered from model/**/*.yaml by tools/docs_model during mkdocs build. Edit the YAML, not this page; hand-written design lives on the linked service, platform and plane pages.

Dialect shown: SQL Server (nvarchar, uniqueidentifier, datetimeoffset). Migrations are authored as FluentMigrator classes in the service's DatabaseModel.Migrations project; the TenantId column and the NHibernate tenant filter follow canonical ADR-0100 in SharedDb mode.

dbo.RunProjections

Owner: RunProjection · Retention: follows the run's retention (1 year default)

CREATE TABLE [dbo].[RunProjections] (
    [RunId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ProjectId] nvarchar(64) NOT NULL,
    [WorkflowId] nvarchar(128) NOT NULL,
    [State] nvarchar(24) NOT NULL,
    [Steps] int NOT NULL DEFAULT (0),
    [Attempts] int NOT NULL DEFAULT (0),
    [ModelCalls] int NOT NULL DEFAULT (0),
    [ToolCalls] int NOT NULL DEFAULT (0),
    [ApprovalsWaiting] int NOT NULL DEFAULT (0),
    [UncertainEffects] int NOT NULL DEFAULT (0),
    [Tokens] bigint NOT NULL DEFAULT (0),
    [CostUsdByStatusJson] nvarchar(512) NOT NULL,
    [DurationMs] bigint NULL,
    [TraceId] nvarchar(64) NOT NULL,
    [LastEventSequence] bigint NOT NULL,
    [UpdatedAt] datetimeoffset NOT NULL,
    CONSTRAINT [PK_RunProjections] PRIMARY KEY ([RunId])
);
CREATE INDEX [IX_RunProjections_Tenant_State_UpdatedAt] ON [dbo].[RunProjections] ([TenantId], [State], [UpdatedAt]);
CREATE INDEX [IX_RunProjections_Project] ON [dbo].[RunProjections] ([ProjectId], [UpdatedAt]);
Column Type Null Key Description
RunId uniqueidentifier no PK
TenantId nvarchar(64) no
ProjectId nvarchar(64) no
WorkflowId nvarchar(128) no
State nvarchar(24) no
Steps int no
Attempts int no
ModelCalls int no
ToolCalls int no
ApprovalsWaiting int no
UncertainEffects int no
Tokens bigint no
CostUsdByStatusJson nvarchar(512) no
DurationMs bigint yes
TraceId nvarchar(64) no
LastEventSequence bigint no
UpdatedAt datetimeoffset no

dbo.TimelineEntries

Owner: TimelineEntry

CREATE TABLE [dbo].[TimelineEntries] (
    [RunId] uniqueidentifier NOT NULL,
    [Sequence] bigint NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [Kind] nvarchar(16) NOT NULL,
    [Reference] nvarchar(256) NOT NULL,
    [Summary] nvarchar(512) NOT NULL,
    [OccurredAt] datetimeoffset NOT NULL,
    [DurationMs] bigint NULL,
    [CostUsd] decimal(18,6) NULL,
    CONSTRAINT [PK_TimelineEntries] PRIMARY KEY ([RunId], [Sequence])
);
ALTER TABLE [dbo].[TimelineEntries] ADD CONSTRAINT [FK_TimelineEntries_RunProjections_RunId] FOREIGN KEY ([RunId]) REFERENCES [dbo].[RunProjections] ([RunId]);
Column Type Null Key Description
RunId uniqueidentifier no PK FK → RunProjections.RunId
Sequence bigint no PK
TenantId nvarchar(64) no
Kind nvarchar(16) no
Reference nvarchar(256) no
Summary nvarchar(512) no
OccurredAt datetimeoffset no
DurationMs bigint yes
CostUsd decimal(18,6) yes

dbo.ProjectionCheckpoints

Owner: RunProjection

CREATE TABLE [dbo].[ProjectionCheckpoints] (
    [Projection] nvarchar(64) NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [LastSequence] bigint NOT NULL,
    [UpdatedAt] datetimeoffset NOT NULL,
    CONSTRAINT [PK_ProjectionCheckpoints] PRIMARY KEY ([Projection], [TenantId])
);
Column Type Null Key Description
Projection nvarchar(64) no PK
TenantId nvarchar(64) no PK
LastSequence bigint no
UpdatedAt datetimeoffset no

dbo.OverviewProjections

Owner: OverviewProjection

CREATE TABLE [dbo].[OverviewProjections] (
    [OverviewId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [Kind] int NOT NULL,
    [SubjectId] nvarchar(128) NOT NULL,
    [Window] nvarchar(8) NOT NULL,
    [MetricsJson] nvarchar(max) NOT NULL,
    [ComputedAt] datetimeoffset NOT NULL,
    CONSTRAINT [PK_OverviewProjections] PRIMARY KEY ([OverviewId])
);
CREATE UNIQUE INDEX [UX_Overview_Subject_Window] ON [dbo].[OverviewProjections] ([TenantId], [Kind], [SubjectId], [Window]);
Column Type Null Key Description
OverviewId uniqueidentifier no PK
TenantId nvarchar(64) no
Kind int no
SubjectId nvarchar(128) no
Window nvarchar(8) no
MetricsJson nvarchar(max) no
ComputedAt datetimeoffset no