Skip to content

ExecutionCapacityService — 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.WorkerPools

Owner: WorkerPool

CREATE TABLE [dbo].[WorkerPools] (
    [PoolId] nvarchar(64) NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [Kind] int NOT NULL,
    [SecurityBoundary] nvarchar(32) NOT NULL,
    [Region] nvarchar(32) NOT NULL,
    [NodeProfile] nvarchar(64) NOT NULL,
    [MinSize] int NOT NULL,
    [MaxSize] int NOT NULL,
    [CurrentSize] int NOT NULL,
    [Utilisation] decimal(5,4) NOT NULL,
    [State] int NOT NULL,
    CONSTRAINT [PK_WorkerPools] PRIMARY KEY ([PoolId])
);
CREATE INDEX [IX_Pools_Kind_Region] ON [dbo].[WorkerPools] ([Kind], [Region], [State]);
Column Type Null Key Description
PoolId nvarchar(64) no PK
TenantId nvarchar(64) no
Kind int no
SecurityBoundary nvarchar(32) no
Region nvarchar(32) no
NodeProfile nvarchar(64) no
MinSize int no
MaxSize int no
CurrentSize int no
Utilisation decimal(5,4) no
State int no

dbo.Quotas

Owner: Quota

CREATE TABLE [dbo].[Quotas] (
    [QuotaId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ProjectId] nvarchar(64) NULL,
    [ConcurrentRuns] int NOT NULL,
    [ConcurrentSandboxes] int NOT NULL,
    [CpuPerAttempt] decimal(6,2) NOT NULL,
    [MemoryGbPerAttempt] decimal(6,2) NOT NULL,
    [ExecutionMinutesPerDay] int NOT NULL,
    [Source] nvarchar(16) NOT NULL,
    CONSTRAINT [PK_Quotas] PRIMARY KEY ([QuotaId])
);
CREATE UNIQUE INDEX [UX_Quotas_Scope] ON [dbo].[Quotas] ([TenantId], [ProjectId]);
Column Type Null Key Description
QuotaId uniqueidentifier no PK
TenantId nvarchar(64) no
ProjectId nvarchar(64) yes
ConcurrentRuns int no
ConcurrentSandboxes int no
CpuPerAttempt decimal(6,2) no
MemoryGbPerAttempt decimal(6,2) no
ExecutionMinutesPerDay int no
Source nvarchar(16) no

dbo.CapacityLeases

Owner: CapacityLease · Retention: 90 days

CREATE TABLE [dbo].[CapacityLeases] (
    [LeaseId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ProjectId] nvarchar(64) NOT NULL,
    [RunId] uniqueidentifier NULL,
    [AttemptId] uniqueidentifier NULL,
    [HolderKind] nvarchar(16) NOT NULL,
    [HolderId] nvarchar(128) NOT NULL,
    [PoolId] nvarchar(64) NOT NULL,
    [Cpu] decimal(6,2) NOT NULL,
    [MemoryGb] decimal(6,2) NOT NULL,
    [State] int NOT NULL,
    [GrantedAt] datetimeoffset NULL,
    [ExpiresAt] datetimeoffset NULL,
    [ReleasedAt] datetimeoffset NULL,
    CONSTRAINT [PK_CapacityLeases] PRIMARY KEY ([LeaseId])
);
ALTER TABLE [dbo].[CapacityLeases] ADD CONSTRAINT [FK_CapacityLeases_WorkerPools_PoolId] FOREIGN KEY ([PoolId]) REFERENCES [dbo].[WorkerPools] ([PoolId]);
CREATE INDEX [IX_Leases_Tenant_State] ON [dbo].[CapacityLeases] ([TenantId], [State]);
CREATE INDEX [IX_Leases_Pool_State] ON [dbo].[CapacityLeases] ([PoolId], [State]);
CREATE INDEX [IX_Leases_Expiry] ON [dbo].[CapacityLeases] ([State], [ExpiresAt]);
Column Type Null Key Description
LeaseId uniqueidentifier no PK
TenantId nvarchar(64) no
ProjectId nvarchar(64) no
RunId uniqueidentifier yes
AttemptId uniqueidentifier yes
HolderKind nvarchar(16) no
HolderId nvarchar(128) no
PoolId nvarchar(64) no FK → WorkerPools.PoolId
Cpu decimal(6,2) no
MemoryGb decimal(6,2) no
State int no
GrantedAt datetimeoffset yes
ExpiresAt datetimeoffset yes
ReleasedAt datetimeoffset yes