u
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
export const INSERT = `
|
||||
INSERT INTO articlehistory (article_id, companyuser_id, [text])
|
||||
VALUES (@articleId, @companyuserId, @text)
|
||||
INSERT INTO articlehistory (article_id, companyuser_id, [date], [text], meta)
|
||||
VALUES (@articleId, @companyuserId, COALESCE(@date, SYSUTCDATETIME()), @text, @meta)
|
||||
`;
|
||||
|
||||
export const LIST_BY_ARTICLE_ID = `
|
||||
SELECT id, companyuser_id AS companyuserId, [date], [text]
|
||||
SELECT id, companyuser_id AS companyuserId, [date], [text], meta
|
||||
FROM articlehistory
|
||||
WHERE article_id = @articleId
|
||||
ORDER BY [date] DESC, id DESC
|
||||
`;
|
||||
|
||||
export const LIST_BY_ARTICLE_ID_LIMITED = `
|
||||
SELECT TOP (@limit) id, companyuser_id AS companyuserId, [date], [text]
|
||||
SELECT TOP (@limit) id, companyuser_id AS companyuserId, [date], [text], meta
|
||||
FROM articlehistory
|
||||
WHERE article_id = @articleId
|
||||
ORDER BY [date] DESC, id DESC
|
||||
|
||||
@@ -38,8 +38,8 @@ WHERE sku = @sku
|
||||
`;
|
||||
|
||||
export const INSERT_ARTICLE_HISTORY = `
|
||||
INSERT INTO articlehistory (article_id, companyuser_id, [text])
|
||||
VALUES (@articleId, @companyuserId, @text);
|
||||
INSERT INTO articlehistory (article_id, companyuser_id, [date], [text], meta)
|
||||
VALUES (@articleId, @companyuserId, COALESCE(@date, SYSUTCDATETIME()), @text, @meta);
|
||||
`;
|
||||
|
||||
export const GET_LATEST_ROW = `
|
||||
|
||||
@@ -372,6 +372,7 @@ BEGIN
|
||||
companyuser_id INT NULL,
|
||||
[date] DATETIME2 NOT NULL CONSTRAINT DF_articlehistory_date DEFAULT SYSUTCDATETIME(),
|
||||
[text] NVARCHAR(MAX) NOT NULL,
|
||||
meta NVARCHAR(MAX) NULL,
|
||||
CONSTRAINT FK_articlehistory_article FOREIGN KEY (article_id) REFERENCES article(id) ON DELETE CASCADE,
|
||||
CONSTRAINT FK_articlehistory_companyuser FOREIGN KEY (companyuser_id) REFERENCES companyuser(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ const queries = translateQueries(source, 'articlehistory');
|
||||
export const { INSERT, LIST_BY_ARTICLE_ID } = queries;
|
||||
|
||||
export const LIST_BY_ARTICLE_ID_LIMITED = `
|
||||
SELECT id, companyuser_id AS companyuserId, date, text
|
||||
SELECT id, companyuser_id AS companyuserId, date, text, meta
|
||||
FROM articlehistory
|
||||
WHERE article_id = @articleId
|
||||
ORDER BY date DESC, id DESC
|
||||
|
||||
@@ -38,8 +38,8 @@ WHERE sku = @sku
|
||||
`;
|
||||
|
||||
export const INSERT_ARTICLE_HISTORY = `
|
||||
INSERT INTO articlehistory (article_id, companyuser_id, text)
|
||||
VALUES (@articleId, @companyuserId, @text);
|
||||
INSERT INTO articlehistory (article_id, companyuser_id, date, text, meta)
|
||||
VALUES (@articleId, @companyuserId, COALESCE(@date, strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), @text, @meta);
|
||||
`;
|
||||
|
||||
export const GET_LATEST_ROW = `
|
||||
|
||||
@@ -551,6 +551,7 @@ CREATE TABLE IF NOT EXISTS articlehistory (
|
||||
companyuser_id INTEGER,
|
||||
"date" TEXT NOT NULL DEFAULT (${UTC_NOW}),
|
||||
"text" TEXT NOT NULL,
|
||||
meta TEXT,
|
||||
FOREIGN KEY (article_id) REFERENCES article(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (companyuser_id) REFERENCES companyuser(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user