This commit is contained in:
seb
2026-09-25 12:30:45 +02:00
parent b5255bdd17
commit 607e6cc0ac
10 changed files with 98 additions and 124 deletions

View File

@@ -312,6 +312,7 @@ IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'article')
BEGIN
CREATE TABLE article (
id INT IDENTITY(1,1) PRIMARY KEY,
company_id INT NOT NULL,
sku NVARCHAR(100) NULL,
unit_id INT NOT NULL,
unitamount FLOAT NOT NULL,
@@ -324,12 +325,13 @@ BEGIN
fathersort INT NOT NULL CONSTRAINT DF_article_fathersort DEFAULT 0,
created_at DATETIME2 NOT NULL CONSTRAINT DF_article_created_at DEFAULT SYSUTCDATETIME(),
updated_at DATETIME2 NOT NULL CONSTRAINT DF_article_updated_at DEFAULT SYSUTCDATETIME(),
CONSTRAINT FK_article_company FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE NO ACTION,
CONSTRAINT FK_article_unit FOREIGN KEY (unit_id) REFERENCES unit(id) ON DELETE NO ACTION,
CONSTRAINT FK_article_brand FOREIGN KEY (brand_id) REFERENCES brand(id) ON DELETE SET NULL,
CONSTRAINT FK_article_articlelist FOREIGN KEY (articlelist_id) REFERENCES articlelist(id) ON DELETE SET NULL,
CONSTRAINT FK_article_optionslist FOREIGN KEY (optionslist_id) REFERENCES optionslist(id) ON DELETE SET NULL,
CONSTRAINT FK_article_fatherarticle FOREIGN KEY (fatherarticle_id) REFERENCES article(id) ON DELETE NO ACTION,
CONSTRAINT UQ_article_sku UNIQUE (sku)
CONSTRAINT UQ_article_company_sku UNIQUE (company_id, sku)
);
-- Only enforce sibling sort uniqueness among children of the same father.