This commit is contained in:
seb
2026-10-18 20:48:47 +02:00
parent 8cc7d0eb0b
commit 9ed7e4ee3b
11 changed files with 201 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
/** Drop order = reverse of schema create dependency order. */
export const TABLES = [
'healthcheck',
'articlewarehousesummary',
'deliverysummary',
'shipmentsummary',

View File

@@ -0,0 +1,19 @@
export const ENSURE_ROW = `
IF NOT EXISTS (SELECT 1 FROM healthcheck)
BEGIN
INSERT INTO healthcheck ([sequence]) VALUES (0);
END
`;
export const SELECT_FOR_UPDATE = `
SELECT TOP 1 id, [sequence]
FROM healthcheck WITH (UPDLOCK, ROWLOCK)
ORDER BY id ASC;
`;
export const UPDATE_SEQUENCE = `
UPDATE healthcheck
SET [sequence] = @sequence,
updated_at = SYSUTCDATETIME()
WHERE id = @id;
`;

View File

@@ -1437,8 +1437,20 @@ BEGIN
END
`;
export const INIT_HEALTHCHECK = `
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'healthcheck')
BEGIN
CREATE TABLE healthcheck (
id INT IDENTITY(1,1) PRIMARY KEY,
[sequence] BIGINT NOT NULL CONSTRAINT DF_healthcheck_sequence DEFAULT 0,
updated_at DATETIME2 NOT NULL CONSTRAINT DF_healthcheck_updated_at DEFAULT SYSUTCDATETIME()
);
END
`;
/** DDL scripts in dependency order for schema init. */
export const SCHEMA_SCRIPTS = [
INIT_HEALTHCHECK,
INIT_META,
INIT_LANGUAGE,
INIT_TAX,