u
This commit is contained in:
@@ -6,7 +6,7 @@ SELECT
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid,
|
||||
maxknownobituaryid AS maxknownobituaryid,
|
||||
root_category_id AS rootCategoryId,
|
||||
sync_root_articles AS syncRootArticles,
|
||||
lastseen_at AS lastseenAt,
|
||||
@@ -25,7 +25,7 @@ SELECT
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid,
|
||||
maxknownobituaryid AS maxknownobituaryid,
|
||||
root_category_id AS rootCategoryId,
|
||||
sync_root_articles AS syncRootArticles,
|
||||
lastseen_at AS lastseenAt,
|
||||
@@ -43,7 +43,7 @@ SELECT
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid,
|
||||
maxknownobituaryid AS maxknownobituaryid,
|
||||
root_category_id AS rootCategoryId,
|
||||
sync_root_articles AS syncRootArticles,
|
||||
lastseen_at AS lastseenAt,
|
||||
@@ -59,14 +59,14 @@ WHERE id = @id
|
||||
`;
|
||||
|
||||
export const CREATE = `
|
||||
INSERT INTO posterminal (company_id, name, token, pairingpin, paired_at, clientserial, maxknowntombstoneid, root_category_id, sync_root_articles, lastseen_at, updated_at)
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.token, INSERTED.pairingpin, INSERTED.paired_at AS pairedAt, INSERTED.clientserial AS clientserial, INSERTED.maxknowntombstoneid AS maxknowntombstoneid, INSERTED.root_category_id AS rootCategoryId, INSERTED.sync_root_articles AS syncRootArticles, INSERTED.lastseen_at AS lastseenAt, INSERTED.updated_at AS updatedAt
|
||||
VALUES (@companyId, @name, @token, @pairingpin, @pairedAt, @clientserial, @maxknowntombstoneid, @rootCategoryId, @syncRootArticles, @lastseenAt, SYSUTCDATETIME())
|
||||
INSERT INTO posterminal (company_id, name, token, pairingpin, paired_at, clientserial, maxknownobituaryid, root_category_id, sync_root_articles, lastseen_at, updated_at)
|
||||
OUTPUT INSERTED.id, INSERTED.name, INSERTED.token, INSERTED.pairingpin, INSERTED.paired_at AS pairedAt, INSERTED.clientserial AS clientserial, INSERTED.maxknownobituaryid AS maxknownobituaryid, INSERTED.root_category_id AS rootCategoryId, INSERTED.sync_root_articles AS syncRootArticles, INSERTED.lastseen_at AS lastseenAt, INSERTED.updated_at AS updatedAt
|
||||
VALUES (@companyId, @name, @token, @pairingpin, @pairedAt, @clientserial, @maxknownobituaryid, @rootCategoryId, @syncRootArticles, @lastseenAt, SYSUTCDATETIME())
|
||||
`;
|
||||
|
||||
export const UPDATE = `
|
||||
UPDATE posterminal
|
||||
SET name = @name, token = @token, pairingpin = @pairingpin, paired_at = @pairedAt, clientserial = @clientserial, maxknowntombstoneid = @maxknowntombstoneid, root_category_id = @rootCategoryId, sync_root_articles = @syncRootArticles, lastseen_at = @lastseenAt, updated_at = SYSUTCDATETIME()
|
||||
SET name = @name, token = @token, pairingpin = @pairingpin, paired_at = @pairedAt, clientserial = @clientserial, maxknownobituaryid = @maxknownobituaryid, root_category_id = @rootCategoryId, sync_root_articles = @syncRootArticles, lastseen_at = @lastseenAt, updated_at = SYSUTCDATETIME()
|
||||
WHERE id = @id AND company_id = @companyId
|
||||
`;
|
||||
|
||||
@@ -76,9 +76,9 @@ SET lastseen_at = SYSUTCDATETIME()
|
||||
WHERE id = @id
|
||||
`;
|
||||
|
||||
export const SET_MAX_KNOWN_TOMBSTONE_ID = `
|
||||
export const SET_MAX_KNOWN_OBITUARY_ID = `
|
||||
UPDATE posterminal
|
||||
SET maxknowntombstoneid = @maxknowntombstoneid
|
||||
SET maxknownobituaryid = @maxknownobituaryid
|
||||
WHERE id = @id
|
||||
`;
|
||||
|
||||
@@ -150,7 +150,7 @@ SELECT
|
||||
pairingpin,
|
||||
paired_at AS pairedAt,
|
||||
clientserial AS clientserial,
|
||||
maxknowntombstoneid AS maxknowntombstoneid,
|
||||
maxknownobituaryid AS maxknownobituaryid,
|
||||
root_category_id AS rootCategoryId,
|
||||
sync_root_articles AS syncRootArticles,
|
||||
lastseen_at AS lastseenAt,
|
||||
@@ -483,8 +483,8 @@ WHERE pr.minmultiplier = 1
|
||||
GROUP BY pr.article_id, pr.customergroup_id
|
||||
`;
|
||||
|
||||
export const RECORD_TOMBSTONE = `
|
||||
INSERT INTO posterminaltombstone (posterminal_id, entity_type, entity_id)
|
||||
export const RECORD_OBITUARY = `
|
||||
INSERT INTO posterminalobituary (posterminal_id, entity_type, entity_id)
|
||||
SELECT pt.id, @entityType, @entityId
|
||||
FROM posterminal pt
|
||||
WHERE pt.company_id = @companyId AND pt.token IS NOT NULL
|
||||
@@ -492,7 +492,7 @@ WHERE pt.company_id = @companyId AND pt.token IS NOT NULL
|
||||
|
||||
export const COUNT_DELETED_ENTITIES = `
|
||||
SELECT COUNT(*) AS count
|
||||
FROM posterminaltombstone
|
||||
FROM posterminalobituary
|
||||
WHERE posterminal_id = @posterminalId AND id > @cursor
|
||||
`;
|
||||
|
||||
@@ -501,7 +501,7 @@ SELECT TOP (@limit)
|
||||
id,
|
||||
entity_type AS entityType,
|
||||
entity_id AS entityId
|
||||
FROM posterminaltombstone
|
||||
FROM posterminalobituary
|
||||
WHERE posterminal_id = @posterminalId AND id > @cursor
|
||||
ORDER BY id ASC
|
||||
`;
|
||||
|
||||
@@ -392,20 +392,20 @@ BEGIN
|
||||
END
|
||||
`;
|
||||
|
||||
export const INIT_POSTERMINALTOMBSTONE = `
|
||||
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'posterminaltombstone')
|
||||
export const INIT_POSTERMINALOBITUARY = `
|
||||
IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'posterminalobituary')
|
||||
BEGIN
|
||||
CREATE TABLE posterminaltombstone (
|
||||
CREATE TABLE posterminalobituary (
|
||||
id INT IDENTITY(1,1) PRIMARY KEY,
|
||||
posterminal_id INT NOT NULL,
|
||||
entity_type NVARCHAR(50) NOT NULL,
|
||||
entity_id INT NOT NULL,
|
||||
created_at DATETIME2 NOT NULL CONSTRAINT DF_posterminaltombstone_created_at DEFAULT SYSUTCDATETIME(),
|
||||
CONSTRAINT FK_posterminaltombstone_posterminal FOREIGN KEY (posterminal_id) REFERENCES posterminal(id) ON DELETE CASCADE
|
||||
created_at DATETIME2 NOT NULL CONSTRAINT DF_posterminalobituary_created_at DEFAULT SYSUTCDATETIME(),
|
||||
CONSTRAINT FK_posterminalobituary_posterminal FOREIGN KEY (posterminal_id) REFERENCES posterminal(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IX_posterminaltombstone_posterminal_id
|
||||
ON posterminaltombstone (posterminal_id, id);
|
||||
CREATE INDEX IX_posterminalobituary_posterminal_id
|
||||
ON posterminalobituary (posterminal_id, id);
|
||||
END
|
||||
`;
|
||||
|
||||
@@ -894,7 +894,7 @@ BEGIN
|
||||
pairingpin NVARCHAR(50) NULL,
|
||||
paired_at DATETIME2 NULL,
|
||||
clientserial NVARCHAR(255) NULL,
|
||||
maxknowntombstoneid INT NULL,
|
||||
maxknownobituaryid INT NULL,
|
||||
root_category_id INT NULL,
|
||||
sync_root_articles BIT NOT NULL CONSTRAINT DF_posterminal_sync_root_articles DEFAULT 1,
|
||||
lastseen_at DATETIME2 NULL,
|
||||
@@ -1503,7 +1503,7 @@ export const SCHEMA_SCRIPTS = [
|
||||
INIT_COMPANYSETTING,
|
||||
INIT_POSTERMINAL,
|
||||
INIT_POSTERMINALCATEGORY,
|
||||
INIT_POSTERMINALTOMBSTONE,
|
||||
INIT_POSTERMINALOBITUARY,
|
||||
INIT_PRINTER,
|
||||
INIT_LABELTEMPLATE,
|
||||
INIT_FILE,
|
||||
|
||||
@@ -479,8 +479,8 @@ export class BetterSqlite3Provider extends BetterSqlite3Executor {
|
||||
if (posterminalCols.length > 0 && !posterminalCols.includes('clientserial')) {
|
||||
this.db.exec(`ALTER TABLE posterminal ADD COLUMN clientserial TEXT`);
|
||||
}
|
||||
if (posterminalCols.length > 0 && !posterminalCols.includes('maxknowntombstoneid')) {
|
||||
this.db.exec(`ALTER TABLE posterminal ADD COLUMN maxknowntombstoneid INTEGER`);
|
||||
if (posterminalCols.length > 0 && !posterminalCols.includes('maxknownobituaryid')) {
|
||||
this.db.exec(`ALTER TABLE posterminal ADD COLUMN maxknownobituaryid INTEGER`);
|
||||
}
|
||||
|
||||
const propertynameCols = this.db.pragma('table_info("propertyname")').map((c) => c.name);
|
||||
|
||||
@@ -5,11 +5,11 @@ const queries = translateQueries(source, 'posterminal');
|
||||
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, SET_MAX_KNOWN_TOMBSTONE_ID,
|
||||
FIND_BY_PAIRINGPIN, PAIR, SET_MAX_KNOWN_OBITUARY_ID,
|
||||
FIND_BY_TOKEN, COUNT_PRODUCTS, COUNT_CATEGORIES, COUNT_CUSTOMERS,
|
||||
COUNT_CUSTOMER_GROUPS, COUNT_COMPOSITE_PRODUCTS, MAX_ORDER_ID,
|
||||
LIST_POS_PRODUCT_CATEGORIES, LIST_POS_CUSTOMER_GROUP_IDS, LIST_POS_PRODUCT_PRICES,
|
||||
TOUCH_LASTSEEN, RECORD_TOMBSTONE, COUNT_DELETED_ENTITIES,
|
||||
TOUCH_LASTSEEN, RECORD_OBITUARY, COUNT_DELETED_ENTITIES,
|
||||
} = queries;
|
||||
|
||||
export const SET_ON = `
|
||||
@@ -269,7 +269,7 @@ SELECT
|
||||
id,
|
||||
entity_type AS entityType,
|
||||
entity_id AS entityId
|
||||
FROM posterminaltombstone
|
||||
FROM posterminalobituary
|
||||
WHERE posterminal_id = @posterminalId AND id > @cursor
|
||||
ORDER BY id ASC
|
||||
LIMIT @limit
|
||||
|
||||
@@ -608,7 +608,7 @@ CREATE TABLE IF NOT EXISTS posterminal (
|
||||
pairingpin TEXT,
|
||||
paired_at TEXT,
|
||||
clientserial TEXT,
|
||||
maxknowntombstoneid INTEGER,
|
||||
maxknownobituaryid INTEGER,
|
||||
root_category_id INTEGER,
|
||||
sync_root_articles INTEGER NOT NULL DEFAULT 1,
|
||||
lastseen_at TEXT,
|
||||
@@ -631,8 +631,8 @@ CREATE TABLE IF NOT EXISTS posterminalcategory (
|
||||
);
|
||||
`;
|
||||
|
||||
export const INIT_POSTERMINALTOMBSTONE = `
|
||||
CREATE TABLE IF NOT EXISTS posterminaltombstone (
|
||||
export const INIT_POSTERMINALOBITUARY = `
|
||||
CREATE TABLE IF NOT EXISTS posterminalobituary (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
posterminal_id INTEGER NOT NULL,
|
||||
entity_type TEXT NOT NULL,
|
||||
@@ -640,8 +640,8 @@ CREATE TABLE IF NOT EXISTS posterminaltombstone (
|
||||
created_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
|
||||
FOREIGN KEY (posterminal_id) REFERENCES posterminal(id) ON DELETE CASCADE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS IX_posterminaltombstone_posterminal_id
|
||||
ON posterminaltombstone (posterminal_id, id);
|
||||
CREATE INDEX IF NOT EXISTS IX_posterminalobituary_posterminal_id
|
||||
ON posterminalobituary (posterminal_id, id);
|
||||
`;
|
||||
|
||||
export const INIT_PRINTER = `
|
||||
@@ -1119,7 +1119,7 @@ export const SCHEMA_SCRIPTS = [
|
||||
INIT_COMPANYSETTING,
|
||||
INIT_POSTERMINAL,
|
||||
INIT_POSTERMINALCATEGORY,
|
||||
INIT_POSTERMINALTOMBSTONE,
|
||||
INIT_POSTERMINALOBITUARY,
|
||||
INIT_PRINTER,
|
||||
INIT_LABELTEMPLATE,
|
||||
INIT_FILE,
|
||||
|
||||
Reference in New Issue
Block a user