Fix posterminal token uniqueness for nullable column

Replace inline UNIQUE constraint with filtered unique index on token
column to allow multiple NULL values while maintaining uniqueness
for non-NULL tokens.
This commit is contained in:
seb
2026-08-03 07:13:36 +02:00
parent 829ab19f59
commit f8e52549d6

View File

@@ -577,9 +577,9 @@ BEGIN
name NVARCHAR(255) NOT NULL,
token NVARCHAR(255) NULL,
pairingpin NVARCHAR(50) NOT NULL,
CONSTRAINT FK_posterminal_company FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE,
CONSTRAINT UQ_posterminal_token UNIQUE (token)
CONSTRAINT FK_posterminal_company FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX UQ_posterminal_token ON posterminal(token) WHERE token IS NOT NULL;
END
`;