u
This commit is contained in:
@@ -845,6 +845,37 @@ CREATE TABLE IF NOT EXISTS package (
|
||||
);
|
||||
`;
|
||||
|
||||
export const INIT_ORDERSUMMARY = `
|
||||
CREATE TABLE IF NOT EXISTS ordersummary (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
company_id INTEGER NOT NULL,
|
||||
manifest_id INTEGER NOT NULL UNIQUE,
|
||||
order_number TEXT NOT NULL,
|
||||
order_date TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (${UTC_NOW}),
|
||||
entity_id INTEGER NULL,
|
||||
customer_name TEXT NULL,
|
||||
positions INTEGER NOT NULL DEFAULT 0,
|
||||
gross_total REAL NOT NULL DEFAULT 0,
|
||||
paid_total REAL NOT NULL DEFAULT 0,
|
||||
ordered_quantity REAL NOT NULL DEFAULT 0,
|
||||
shipped_quantity REAL NOT NULL DEFAULT 0,
|
||||
is_paid INTEGER NOT NULL DEFAULT 0,
|
||||
is_shipped INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY (company_id) REFERENCES company(id) ON DELETE NO ACTION,
|
||||
FOREIGN KEY (manifest_id) REFERENCES manifest(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (entity_id) REFERENCES entity(id) ON DELETE SET NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS IX_ordersummary_company_date
|
||||
ON ordersummary (company_id, order_date DESC, manifest_id DESC);
|
||||
CREATE INDEX IF NOT EXISTS IX_ordersummary_company_shipped
|
||||
ON ordersummary (company_id, is_shipped);
|
||||
CREATE INDEX IF NOT EXISTS IX_ordersummary_company_paid
|
||||
ON ordersummary (company_id, is_paid);
|
||||
CREATE INDEX IF NOT EXISTS IX_ordersummary_company_number
|
||||
ON ordersummary (company_id, order_number);
|
||||
`;
|
||||
|
||||
export const INIT_MCP_CLIENT = `
|
||||
CREATE TABLE IF NOT EXISTS mcp_client (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -953,6 +984,7 @@ export const SCHEMA_SCRIPTS = [
|
||||
INIT_PAYMENT,
|
||||
INIT_SHIPPING,
|
||||
INIT_PACKAGE,
|
||||
INIT_ORDERSUMMARY,
|
||||
INIT_MCP_CLIENT,
|
||||
INIT_MCP_AUTH_CODE,
|
||||
INIT_MCP_TOKEN,
|
||||
|
||||
Reference in New Issue
Block a user