This commit is contained in:
@@ -656,13 +656,35 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
|
||||
//CONTRACT
|
||||
await ExecQueryAsync("CREATE TABLE acontract (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, active BOOL NOT NULL, "
|
||||
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, "
|
||||
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, "
|
||||
+ "responsetime INTERVAL NOT NULL, contractratesonly BOOL NOT NULL, partsoverride DECIMAL(5,5) NOT NULL, partsoverridetype INTEGER NOT NULL, "
|
||||
+ "serviceratesoverride DECIMAL(5,5) NOT NULL, serviceratesoverridetype INTEGER NOT NULL, travelratesoverride DECIMAL(5,5) NOT NULL, travelratesoverridetype INTEGER NOT NULL, "
|
||||
+"alertnotes text "
|
||||
+ "alertnotes text "
|
||||
+ ")");
|
||||
await ExecQueryAsync("ALTER TABLE acustomer ADD column contractid BIGINT NULL REFERENCES acontract");
|
||||
|
||||
//CONTRACTSERVICERATE
|
||||
await ExecQueryAsync("CREATE TABLE acontractservicerate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, contractid BIGINT NOT NULL REFERENCES acontract ON DELETE CASCADE, "
|
||||
+ "servicerateid BIGINT NOT NULL REFERENCES aservicerate ON DELETE CASCADE"
|
||||
+ ")");
|
||||
|
||||
//CONTRACTTRAVELERATE
|
||||
await ExecQueryAsync("CREATE TABLE acontracttravelrate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, contractid BIGINT NOT NULL REFERENCES acontract ON DELETE CASCADE, "
|
||||
+ "travelrateid BIGINT NOT NULL REFERENCES atravelrate ON DELETE CASCADE"
|
||||
+ ")");
|
||||
|
||||
//CONTRACTPARTOVERRIDE
|
||||
await ExecQueryAsync("CREATE TABLE acontractpartoverride (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, contractid BIGINT NOT NULL REFERENCES acontract ON DELETE CASCADE, "
|
||||
+ " override DECIMAL(5,5) NOT NULL, overridetype INTEGER NOT NULL, tags VARCHAR(255) ARRAY)");
|
||||
|
||||
//CONTRACTSERVICERATEOVERRIDE
|
||||
await ExecQueryAsync("CREATE TABLE acontractservicerateoverride (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, contractid BIGINT NOT NULL REFERENCES acontract ON DELETE CASCADE, "
|
||||
+ " override DECIMAL(5,5) NOT NULL, overridetype INTEGER NOT NULL, tags VARCHAR(255) ARRAY)");
|
||||
|
||||
//CONTRACTTRAVELRATEOVERRIDE
|
||||
await ExecQueryAsync("CREATE TABLE acontracttravelrateoverride (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, contractid BIGINT NOT NULL REFERENCES acontract ON DELETE CASCADE, "
|
||||
+ " override DECIMAL(5,5) NOT NULL, overridetype INTEGER NOT NULL, tags VARCHAR(255) ARRAY)");
|
||||
|
||||
|
||||
//HEADOFFICE
|
||||
await ExecQueryAsync("CREATE TABLE aheadoffice (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, active BOOL NOT NULL, "
|
||||
@@ -818,7 +840,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
|
||||
//POITEM LINK
|
||||
await ExecQueryAsync("ALTER TABLE apurchaseorderitem ADD column workorderitempartrequestid BIGINT REFERENCES aworkorderitempartrequest");
|
||||
|
||||
|
||||
//VPARTSONORDERUNCOMMITTED
|
||||
await ExecQueryAsync("CREATE VIEW vpartsonorderuncommitted AS SELECT partid, partwarehouseid, SUM((COALESCE(apurchaseorderitem.quantityordered,0)-COALESCE(apurchaseorderitem.quantityreceived,0))) AS quantityonorder "
|
||||
+ "FROM apurchaseorderitem WHERE workorderitempartrequestid IS NULL AND (COALESCE(apurchaseorderitem.quantityordered,0)-COALESCE(apurchaseorderitem.quantityreceived,0)) > 0 GROUP BY partid, partwarehouseid");
|
||||
|
||||
Reference in New Issue
Block a user