Skip to content

Commit c627336

Browse files
committed
Merge branch 'improvement/SQL-topic-constraint' into develop
This ensures that a topic with the same key as another topic cannot exist within the same parent scope. This is already enforced by the Topic Library itself, but not by the SQL schema. This helps prevent inadvertent conflicts from being introduced when manually updating the SQL database, which would result in an exception when loading the data via an `ITopicRepository` implementation. This resolves #106.
2 parents b62daf9 + f0cc9ab commit c627336

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

OnTopic.Data.Sql.Database/Tables/Topics.sql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ TABLE [dbo].[Topics] (
1616
CONSTRAINT [PK_Topics] PRIMARY KEY
1717
CLUSTERED ( [TopicID] ASC
1818
),
19-
CONSTRAINT [FK_Topics_Topics]
20-
FOREIGN KEY ( [ParentID] )
21-
REFERENCES [Topics]([TopicID])
19+
CONSTRAINT [UK_TopicKey]
20+
UNIQUE ( [TopicKey],
21+
[ParentID]
22+
),
23+
CONSTRAINT [FK_Topics_Topics]
24+
FOREIGN KEY ( [ParentID] )
25+
REFERENCES [Topics]([TopicID])
2226
);
2327

2428
GO

0 commit comments

Comments
 (0)