Skip to content

ArtifactService — 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.VersionChains

Owner: Artifact

CREATE TABLE [dbo].[VersionChains] (
    [ChainId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ProjectId] nvarchar(64) NOT NULL,
    [Name] nvarchar(512) NOT NULL,
    [LatestVersion] int NOT NULL DEFAULT (0),
    CONSTRAINT [PK_VersionChains] PRIMARY KEY ([ChainId])
);
CREATE UNIQUE INDEX [UX_Chains_Project_Name] ON [dbo].[VersionChains] ([ProjectId], [Name]);
Column Type Null Key Description
ChainId uniqueidentifier no PK
TenantId nvarchar(64) no
ProjectId nvarchar(64) no
Name nvarchar(512) no
LatestVersion int no

dbo.Artifacts

Owner: Artifact · Retention: 1 year by default per project (D31); exported on request; content removed on deletion

CREATE TABLE [dbo].[Artifacts] (
    [ArtifactId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [ProjectId] nvarchar(64) NOT NULL,
    [Kind] int NOT NULL,
    [Name] nvarchar(512) NOT NULL,
    [ContentHash] nvarchar(128) NOT NULL,
    [ContentRef] nvarchar(512) NOT NULL,
    [SizeBytes] bigint NOT NULL,
    [MediaType] nvarchar(128) NOT NULL,
    [Classification] nvarchar(16) NOT NULL,
    [AccessScopeJson] nvarchar(2000) NOT NULL,
    [ProducerRunId] uniqueidentifier NULL,
    [ProducerAttemptId] uniqueidentifier NULL,
    [ProducerAgentId] nvarchar(128) NULL,
    [ChainId] uniqueidentifier NOT NULL,
    [VersionInChain] int NOT NULL,
    [State] int NOT NULL,
    [ValidationRef] nvarchar(512) NULL,
    [CreatedAt] datetimeoffset NOT NULL,
    CONSTRAINT [PK_Artifacts] PRIMARY KEY ([ArtifactId])
);
ALTER TABLE [dbo].[Artifacts] ADD CONSTRAINT [FK_Artifacts_VersionChains_ChainId] FOREIGN KEY ([ChainId]) REFERENCES [dbo].[VersionChains] ([ChainId]);
CREATE UNIQUE INDEX [UX_Artifacts_Chain_Version] ON [dbo].[Artifacts] ([ChainId], [VersionInChain]);
CREATE INDEX [IX_Artifacts_Tenant_Hash] ON [dbo].[Artifacts] ([TenantId], [ContentHash]);
CREATE INDEX [IX_Artifacts_ProducerRun] ON [dbo].[Artifacts] ([ProducerRunId]);
Column Type Null Key Description
ArtifactId uniqueidentifier no PK
TenantId nvarchar(64) no
ProjectId nvarchar(64) no
Kind int no
Name nvarchar(512) no
ContentHash nvarchar(128) no
ContentRef nvarchar(512) no
SizeBytes bigint no
MediaType nvarchar(128) no
Classification nvarchar(16) no
AccessScopeJson nvarchar(2000) no
ProducerRunId uniqueidentifier yes
ProducerAttemptId uniqueidentifier yes
ProducerAgentId nvarchar(128) yes
ChainId uniqueidentifier no FK → VersionChains.ChainId
VersionInChain int no
State int no
ValidationRef nvarchar(512) yes
CreatedAt datetimeoffset no

dbo.LineageEdges

Owner: LineageEdge

CREATE TABLE [dbo].[LineageEdges] (
    [EdgeId] uniqueidentifier NOT NULL,
    [ArtifactId] uniqueidentifier NOT NULL,
    [TenantId] nvarchar(64) NOT NULL,
    [InputKind] nvarchar(24) NOT NULL,
    [InputRef] nvarchar(512) NOT NULL,
    [Relation] nvarchar(24) NOT NULL,
    CONSTRAINT [PK_LineageEdges] PRIMARY KEY ([EdgeId])
);
ALTER TABLE [dbo].[LineageEdges] ADD CONSTRAINT [FK_LineageEdges_Artifacts_ArtifactId] FOREIGN KEY ([ArtifactId]) REFERENCES [dbo].[Artifacts] ([ArtifactId]);
CREATE INDEX [IX_Lineage_Input] ON [dbo].[LineageEdges] ([TenantId], [InputKind], [InputRef]);
Column Type Null Key Description
EdgeId uniqueidentifier no PK
ArtifactId uniqueidentifier no FK → Artifacts.ArtifactId
TenantId nvarchar(64) no
InputKind nvarchar(24) no
InputRef nvarchar(512) no
Relation nvarchar(24) no