This commit is contained in:
seb
2026-09-30 09:48:01 +02:00
parent 9885c489f0
commit 280a45a11f
28 changed files with 539 additions and 16 deletions

View File

@@ -431,6 +431,18 @@ export class BetterSqlite3Provider extends BetterSqlite3Executor {
if (propertynameCols.length > 0 && !propertynameCols.includes('exclusive')) {
this.db.exec(`ALTER TABLE propertyname ADD COLUMN exclusive INTEGER NOT NULL DEFAULT 0`);
}
const categoryCols = this.db.pragma('table_info("category")').map((c) => c.name);
if (categoryCols.length > 0 && !categoryCols.includes('updated_at')) {
this.db.exec(`ALTER TABLE category ADD COLUMN updated_at TEXT`);
this.db.exec(`UPDATE category SET updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now') WHERE updated_at IS NULL`);
}
const customergroupCols = this.db.pragma('table_info("customergroup")').map((c) => c.name);
if (customergroupCols.length > 0 && !customergroupCols.includes('updated_at')) {
this.db.exec(`ALTER TABLE customergroup ADD COLUMN updated_at TEXT`);
this.db.exec(`UPDATE customergroup SET updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now') WHERE updated_at IS NULL`);
}
} catch {
// ignore
}

View File

@@ -65,6 +65,7 @@ FROM categoryarticle ca
INNER JOIN article a ON a.id = ca.article_id
${ARTICLE_LIST_JOINS}
WHERE ca.category_id = @categoryId
AND a.fatherarticle_id IS NULL
ORDER BY a.id
`;

View File

@@ -6,6 +6,8 @@ export const {
CREATE, DELETE_BY_COMPANY_AND_ID, GET_BY_ID, LIST_BY_COMPANY,
LIST_CATEGORY_IDS, POSTERMINAL_IDS_BY_COMPANY, SET_OFF, SET_OFF_ALL, UPDATE,
FIND_BY_PAIRINGPIN, PAIR,
FIND_BY_TOKEN, COUNT_PRODUCTS, COUNT_CATEGORIES, COUNT_CUSTOMERS,
COUNT_CUSTOMER_GROUPS, COUNT_COMPOSITE_PRODUCTS, MAX_ORDER_ID,
} = queries;
export const SET_ON = `

View File

@@ -33,6 +33,7 @@ export function sqliteQuery(sql) {
let result = quoteIdentifiers(sql)
.replace(/\bISNULL\s*\(/gi, 'IFNULL(')
.replace(/\bSYSUTCDATETIME\s*\(\s*\)/gi, "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')")
.replace(/\bDATEDIFF_BIG\s*\(\s*second\s*,\s*'1970-01-01'\s*,\s*([^)]+?)\s*\)/gi, "CAST(strftime('%s', $1) AS INTEGER)")
.replace(/\bCAST\s*\(([^()]+?)\s+AS\s+INT\s*\)/gi, 'CAST($1 AS INTEGER)')
.replace(/\bCONVERT\s*\(\s*VARBINARY\s*\(\s*MAX\s*\)\s*,\s*([^)]+?)\s*\)/gi, '$1');
result = moveReturning(result);

View File

@@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS category (
id INTEGER PRIMARY KEY,
parent_id INTEGER,
sort INTEGER NOT NULL DEFAULT 0,
updated_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
FOREIGN KEY (parent_id) REFERENCES category(id) ON DELETE NO ACTION
);
`;
@@ -86,6 +87,7 @@ CREATE TABLE IF NOT EXISTS customergroup (
name TEXT NOT NULL,
sort INTEGER NOT NULL DEFAULT 0,
company_id INTEGER,
updated_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE CASCADE
);
`;