This commit is contained in:
seb
2026-10-22 12:30:06 +02:00
parent bb880e3c84
commit 9495ad51cc
27 changed files with 539 additions and 238 deletions

View File

@@ -21,6 +21,26 @@ export default function setOff(provider) {
? SQLITE_LIST_CATEGORY_IDS
: MSSQL_LIST_CATEGORY_IDS;
const addCategoryTombstoneSql = `
INSERT INTO posterminaltombstone (posterminal_id, entity_type, entity_id)
VALUES (@posterminalId, 'category', @categoryId)
`;
const addArticleTombstonesSql = `
INSERT INTO posterminaltombstone (posterminal_id, entity_type, entity_id)
SELECT DISTINCT @posterminalId, 'article', ca.article_id
FROM categoryarticle ca
WHERE ca.category_id = @categoryId
AND NOT EXISTS (
SELECT 1
FROM categoryarticle ca2
INNER JOIN posterminalcategory pc ON pc.category_id = ca2.category_id
WHERE ca2.article_id = ca.article_id
AND pc.posterminal_id = @posterminalId
AND pc.category_id <> @categoryId
)
`;
/**
* Removes a category assignment from a posterminal (turns it off).
*
@@ -49,6 +69,16 @@ export default function setOff(provider) {
throw new Error('Posterminal not found');
}
await runner.query(addCategoryTombstoneSql, {
posterminalId,
categoryId,
});
await runner.query(addArticleTombstonesSql, {
posterminalId,
categoryId,
});
await runner.query(setOffSql, {
posterminalId,
categoryId,