This commit is contained in:
@@ -37,7 +37,17 @@ namespace AyaNova.Util
|
||||
/*
|
||||
|
||||
MAXIMUM POSTGRES OBJECT NAME LENGTH: 63 CHARACTERS
|
||||
CURRENCY: use DECIMAL(19,4)
|
||||
|
||||
DECIMALS:
|
||||
=-=-=-=--
|
||||
CURRENCY: was use DECIMAL(19,4) (18 bytes) however with cryptocurrencies now potentially being used
|
||||
and the fact that it doesn't practically take up much room or speed to go wider I'm settling on largest Etherium value DECIMAL(38,18) (36bytes)
|
||||
TAX/PERCENTAGES/PDF PAGE SCALE: DECIMAL(5,5) largest tax I could find would fit in this
|
||||
Inventory/incidents general numbers (19,4)
|
||||
|
||||
|
||||
|
||||
|
||||
//DATA TYPES .net to postgres map
|
||||
//http://www.npgsql.org/doc/types/basic.html
|
||||
|
||||
@@ -466,7 +476,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
//Add widget table
|
||||
//id, TEXT, longtext, boolean, currency,
|
||||
await ExecQueryAsync("CREATE TABLE awidget (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, serial BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,"
|
||||
+ "startdate TIMESTAMP, enddate TIMESTAMP, dollaramount DECIMAL(19,4), active BOOL NOT NULL, usertype int4, count INTEGER,"
|
||||
+ "startdate TIMESTAMP, enddate TIMESTAMP, dollaramount DECIMAL(38,18), active BOOL NOT NULL, usertype int4, count INTEGER,"
|
||||
+ "notes TEXT, userid BIGINT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY)");
|
||||
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
@@ -573,17 +583,17 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
//SERVICERATE
|
||||
await ExecQueryAsync("CREATE TABLE aservicerate (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, "
|
||||
+ "accountnumber TEXT, unit TEXT, contractonly BOOL NOT NULL, cost DECIMAL(19,4) NOT NULL default 0, charge DECIMAL(19,4) NOT NULL default 0)");
|
||||
+ "accountnumber TEXT, unit TEXT, contractonly BOOL NOT NULL, cost DECIMAL(38,18) NOT NULL default 0, charge DECIMAL(38,18) NOT NULL default 0)");
|
||||
|
||||
//TRAVELRATE
|
||||
await ExecQueryAsync("CREATE TABLE atravelrate (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, "
|
||||
+ "accountnumber TEXT, unit TEXT, contractonly BOOL NOT NULL, cost DECIMAL(19,4) NOT NULL default 0, charge DECIMAL(19,4) NOT NULL default 0)");
|
||||
+ "accountnumber TEXT, unit TEXT, contractonly BOOL NOT NULL, cost DECIMAL(38,18) NOT NULL default 0, charge DECIMAL(38,18) NOT NULL default 0)");
|
||||
|
||||
//TAXCODE
|
||||
await ExecQueryAsync("CREATE TABLE ataxcode (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, "
|
||||
+ "taxa DECIMAL(19,4) NOT NULL default 0, taxb DECIMAL(19,4) NOT NULL default 0, taxontax BOOL NOT NULL default false)");
|
||||
+ "taxa DECIMAL(5,5) NOT NULL default 0, taxb DECIMAL(5,5) NOT NULL default 0, taxontax BOOL NOT NULL default false)");
|
||||
|
||||
//MEMO
|
||||
await ExecQueryAsync("CREATE TABLE amemo (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, "
|
||||
@@ -616,7 +626,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
await ExecQueryAsync("CREATE TABLE aservicebank (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, "
|
||||
+ "entrydate TIMESTAMP NOT NULL, lastentrydate TIMESTAMP NULL, objecttype INTEGER NOT NULL, objectid BIGINT NOT NULL, sourcetype INTEGER NOT NULL, sourceid BIGINT NOT NULL, "
|
||||
+ "incidents DECIMAL(19,4) NOT NULL, incidentsbalance DECIMAL(19,4) NOT NULL, lastincidentsbalance DECIMAL(19,4) NULL, "
|
||||
+ "currency DECIMAL(19,4) NOT NULL, currencybalance DECIMAL(19,4) NOT NULL, lastcurrencybalance DECIMAL(19,4) NULL, "
|
||||
+ "currency DECIMAL(38,18) NOT NULL, currencybalance DECIMAL(38,18) NOT NULL, lastcurrencybalance DECIMAL(38,18) NULL, "
|
||||
+ "hours DECIMAL(19,4) NOT NULL, hoursbalance DECIMAL(19,4) NOT NULL, lasthoursbalance DECIMAL(19,4) NULL, "
|
||||
+ "CONSTRAINT unq_servicebank UNIQUE (entrydate, objectid, objecttype, incidentsbalance, hoursbalance, currencybalance), "
|
||||
+ "CONSTRAINT unq_servicebank_previous_values UNIQUE (lastentrydate, objectid, objecttype, lastincidentsbalance, lasthoursbalance, lastcurrencybalance), "
|
||||
@@ -646,7 +656,11 @@ $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 "
|
||||
+ ")");
|
||||
await ExecQueryAsync("ALTER TABLE acustomer ADD column contractid BIGINT NULL REFERENCES acontract");
|
||||
|
||||
|
||||
@@ -674,7 +688,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, "
|
||||
+ "partnumber TEXT NOT NULL UNIQUE, manufacturerid BIGINT REFERENCES avendor, manufacturernumber TEXT, "
|
||||
+ "wholesalerid BIGINT REFERENCES avendor, wholesalernumber TEXT, alternativewholesalerid BIGINT REFERENCES avendor, alternativewholesalernumber TEXT, "
|
||||
+ "cost DECIMAL(19,4) NOT NULL, retail DECIMAL(19,4) NOT NULL, unitofmeasure TEXT, upc TEXT "
|
||||
+ "cost DECIMAL(38,18) NOT NULL, retail DECIMAL(38,18) NOT NULL, unitofmeasure TEXT, upc TEXT "
|
||||
+ " )");
|
||||
|
||||
//PARTWAREHOUSE
|
||||
@@ -743,7 +757,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
//PURCHASEORDERITEM
|
||||
await ExecQueryAsync("CREATE TABLE apurchaseorderitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, purchaseorderid BIGINT NOT NULL REFERENCES apurchaseorder ON DELETE CASCADE, "
|
||||
+ "partid BIGINT NOT NULL REFERENCES apart, partwarehouseid BIGINT NOT NULL REFERENCES apartwarehouse, quantityordered DECIMAL(19,4) NOT NULL default 0, "
|
||||
+ "quantityreceived DECIMAL(19,4) NOT NULL default 0, purchaseordercost DECIMAL(19,4) NOT NULL default 0, receivedcost DECIMAL(19,4) NOT NULL default 0, "
|
||||
+ "quantityreceived DECIMAL(19,4) NOT NULL default 0, purchaseordercost DECIMAL(38,18) NOT NULL default 0, receivedcost DECIMAL(38,18) NOT NULL default 0, "
|
||||
+ "receiveddate TIMESTAMP, partrequestedbyid BIGINT REFERENCES auser, purchasetaxcodeid BIGINT REFERENCES ataxcode, vendorpartnumber TEXT, serials TEXT "
|
||||
+ ")");
|
||||
|
||||
@@ -772,7 +786,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
await ExecQueryAsync("CREATE TABLE aloanunit (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, "
|
||||
+ "serial TEXT, unitid BIGINT NULL REFERENCES aunit(id), defaultrate INTEGER NOT NULL, "
|
||||
+ "ratehour DECIMAL(19,4) NOT NULL, ratehalfday DECIMAL(19,4) NOT NULL, rateday DECIMAL(19,4) NOT NULL, rateweek DECIMAL(19,4) NOT NULL, ratemonth DECIMAL(19,4) NOT NULL, rateyear DECIMAL(19,4) NOT NULL "
|
||||
+ "ratehour DECIMAL(38,18) NOT NULL, ratehalfday DECIMAL(38,18) NOT NULL, rateday DECIMAL(38,18) NOT NULL, rateweek DECIMAL(38,18) NOT NULL, ratemonth DECIMAL(38,18) NOT NULL, rateyear DECIMAL(38,18) NOT NULL "
|
||||
+ ")");
|
||||
|
||||
|
||||
@@ -901,8 +915,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
LogUpdateMessage(log);
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE anotifysubscription (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, "
|
||||
+ "userid BIGINT NOT NULL REFERENCES auser (id), ayatype INTEGER NOT NULL, eventtype INTEGER NOT NULL, advancenotice interval NOT NULL, "
|
||||
+ "idvalue BIGINT NOT NULL, decvalue DECIMAL(19,4) NOT NULL, agevalue interval NOT NULL, deliverymethod INTEGER NOT NULL, "
|
||||
+ "userid BIGINT NOT NULL REFERENCES auser (id), ayatype INTEGER NOT NULL, eventtype INTEGER NOT NULL, advancenotice INTERVAL NOT NULL, "
|
||||
+ "idvalue BIGINT NOT NULL, decvalue DECIMAL(38,18) NOT NULL, agevalue INTERVAL NOT NULL, deliverymethod INTEGER NOT NULL, "
|
||||
+ "deliveryaddress TEXT, linkreportid BIGINT NOT NULL, tags VARCHAR(255) ARRAY)");
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created TIMESTAMP NOT NULL, "
|
||||
@@ -910,7 +924,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
+ "userid BIGINT NOT NULL REFERENCES auser (id), eventdate TIMESTAMP NOT NULL, message TEXT)");
|
||||
//these fields were in here but seem to not be required so commented out for now, see notifyevent model for deets but
|
||||
//basically remove this comment once certain don't need these fields (close to release or after)
|
||||
//idvalue BIGINT NOT NULL, decvalue DECIMAL(19,4) NOT NULL,
|
||||
//idvalue BIGINT NOT NULL, decvalue DECIMAL(38,18) NOT NULL,
|
||||
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE anotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userid BIGINT NOT NULL REFERENCES auser (id), "
|
||||
@@ -919,7 +933,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE anotifydeliverylog (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, processed TIMESTAMP NOT NULL, "
|
||||
+ "ayatype INTEGER NOT NULL, objectid BIGINT NOT NULL, eventtype INTEGER NOT NULL, notifysubscriptionid BIGINT NOT NULL, idvalue BIGINT NOT NULL, "
|
||||
+ "decvalue DECIMAL(19,4) NOT NULL, userid BIGINT NOT NULL REFERENCES auser (id), deliverymethod INTEGER NOT NULL, fail BOOL NOT NULL, error TEXT)");
|
||||
+ "decvalue DECIMAL(38,18) NOT NULL, userid BIGINT NOT NULL REFERENCES auser (id), deliverymethod INTEGER NOT NULL, fail BOOL NOT NULL, error TEXT)");
|
||||
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
}
|
||||
@@ -944,7 +958,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
await ExecQueryAsync("CREATE TABLE areport (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, active BOOL NOT NULL, "
|
||||
+ "notes TEXT, roles INTEGER NOT NULL, objecttype INTEGER NOT NULL, template TEXT, style TEXT, jsprerender TEXT, jshelpers TEXT, rendertype INTEGER NOT NULL, "
|
||||
+ "headertemplate TEXT, footertemplate TEXT, displayheaderfooter BOOL, paperformat INTEGER NOT NULL, landscape BOOL, marginoptionsbottom TEXT, "
|
||||
+ "marginoptionsleft TEXT, marginoptionsright TEXT, marginoptionstop TEXT, pageranges TEXT, prefercsspagesize BOOL, printbackground BOOL, scale DECIMAL(19,4) )");
|
||||
+ "marginoptionsleft TEXT, marginoptionsright TEXT, marginoptionstop TEXT, pageranges TEXT, prefercsspagesize BOOL, printbackground BOOL, scale DECIMAL(5,5) )");
|
||||
await SetSchemaLevelAsync(++currentSchema);
|
||||
|
||||
//Load the stock REPORT TEMPLATES
|
||||
|
||||
Reference in New Issue
Block a user