This commit is contained in:
2021-01-15 15:40:07 +00:00
parent 961e52688e
commit 20b843f916
2 changed files with 85 additions and 87 deletions

2
.vscode/launch.json vendored
View File

@@ -53,7 +53,7 @@
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
"AYANOVA_SERVER_TEST_MODE": "false",
"AYANOVA_SERVER_TEST_MODE": "true",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"

View File

@@ -244,10 +244,10 @@ namespace AyaNova.Util
await ExecQueryAsync("CREATE TABLE aevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, userid bigint not null," +
"ayid bigint not null, ayatype integer not null, ayevent integer not null, textra varchar(255))");
//INDEX: Most selective first as there is more unique ID's than unique types
await ExecQueryAsync("CREATE INDEX aevent_typeid_idx ON aevent (ayid, ayatype);");
await ExecQueryAsync("CREATE INDEX idx_aevent_ayid_aytype ON aevent (ayid, ayatype);");
//TODO: this may be a very low used index, revisit it down the road
await ExecQueryAsync("CREATE INDEX aevent_userid_idx ON aevent (userid);");
await ExecQueryAsync("CREATE INDEX idx_aevent_userid ON aevent (userid);");
//METRICS TABLES
@@ -275,7 +275,7 @@ namespace AyaNova.Util
//search does a lot of hits on searchkey looking for the wordid and optionally objecttype
//In testing this did not pan out, in fact it was much faster to search both with and without a objecttype specified to simply have an index on wordid
// await ExecQueryAsync("CREATE INDEX asearchkey_wordid_otype_idx ON asearchkey (wordid, objecttype);");
await ExecQueryAsync("CREATE INDEX asearchkey_wordid_idx ON asearchkey (wordid);");
await ExecQueryAsync("CREATE INDEX idx_asearchkey_wordid ON asearchkey (wordid);");
//Search indexing stored procedure
await ExecQueryAsync(@"
@@ -406,10 +406,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//create translation text tables
await ExecQueryAsync("CREATE TABLE atranslation (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, stock bool, cjkindex bool default false)");
await ExecQueryAsync("CREATE TABLE atranslationitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, translationid bigint not null REFERENCES atranslation (id), key text not null, display text not null)");
//This is not a well used index, not sure what it's point is
// await ExecQueryAsync("CREATE INDEX atranslationitem_translationid_key_display_idx ON atranslationitem (translationid,key, display)");
//Load the default TRANSLATIONS
await AyaNova.Biz.PrimeData.PrimeTranslations();
@@ -422,7 +420,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"headofficeid bigint, vendorid bigint, wiki text, customfields text, tags varchar(255) ARRAY)");
//Index for name fetching
await ExecQueryAsync("CREATE UNIQUE INDEX auser_name_id_idx ON auser (id, name);");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_auser_id_name ON auser (id, name);");
//Add user options table
await ExecQueryAsync("CREATE TABLE auseroptions (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " +
@@ -467,10 +465,10 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//Compound index for name fetching
await ExecQueryAsync("CREATE UNIQUE INDEX awidget_name_id_idx ON awidget (id, name);");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_awidget_id_name ON awidget (id, name);");
//Index for tags
await ExecQueryAsync("CREATE INDEX awidget_tags ON AWIDGET using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_awidget_tags ON AWIDGET using GIN(tags)");
await SetSchemaLevelAsync(++currentSchema);
}
@@ -488,11 +486,11 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//index required for ops that need to check if file already in db (delete, count refs etc)
//LOOKAT: isn't this useless without the ID as well or is that not fetched?
await ExecQueryAsync("CREATE INDEX afileattachment_storedfilename_idx ON afileattachment (storedfilename);");
await ExecQueryAsync("CREATE INDEX idx_afileattachment_storedfilename ON afileattachment (storedfilename);");
//index for the common issue of checking if an object has an attachment and retrieving them
//note always query (where clause) in this same order for best performance
await ExecQueryAsync("CREATE INDEX afileattachment_typeid_idx ON afileattachment (attachtoobjectid, attachtoobjecttype );");
await ExecQueryAsync("CREATE INDEX idx_afileattachment_attachtoobjectid_attachtoobjecttype ON afileattachment (attachtoobjectid, attachtoobjecttype );");
await SetSchemaLevelAsync(++currentSchema);
}
@@ -574,38 +572,38 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
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, cost decimal(19,4) not null default 0, charge decimal(19,4) not null default 0)");
await ExecQueryAsync("CREATE UNIQUE INDEX aservicerate_name_id_idx ON aservicerate (id, name);");
await ExecQueryAsync("CREATE INDEX aservicerate_tags ON aservicerate using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aservicerate_id_name ON aservicerate (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aservicerate_tags ON aservicerate using GIN(tags)");
//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, cost decimal(19,4) not null default 0, charge decimal(19,4) not null default 0)");
await ExecQueryAsync("CREATE UNIQUE INDEX atravelrate_name_id_idx ON atravelrate (id, name);");
await ExecQueryAsync("CREATE INDEX atravelrate_tags ON atravelrate using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_atravelrate_id_name ON atravelrate (id, name);");
await ExecQueryAsync("CREATE INDEX idx_atravelrate_tags ON atravelrate using GIN(tags)");
//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)");
await ExecQueryAsync("CREATE UNIQUE INDEX ataxcode_name_id_idx ON ataxcode (id, name);");
await ExecQueryAsync("CREATE INDEX ataxcode_tags ON ataxcode using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_ataxcode_id_name ON ataxcode (id, name);");
await ExecQueryAsync("CREATE INDEX idx_ataxcode_tags ON ataxcode using GIN(tags)");
//MEMO
await ExecQueryAsync("CREATE TABLE amemo (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
"sent timestamp not null, viewed bool default false, replied bool default false, fromid bigint not null REFERENCES auser(id), toid bigint not null REFERENCES auser(id) )");
await ExecQueryAsync("CREATE INDEX amemo_tags ON amemo using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_amemo_tags ON amemo using GIN(tags)");
//REMINDER
await ExecQueryAsync("CREATE TABLE areminder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
"startdate timestamp not null, stopdate timestamp not null, userid bigint not null references auser(id), color varchar(12) not null default '#ffffff')");
await ExecQueryAsync("CREATE INDEX areminder_userid_idx ON areminder (userid);");
await ExecQueryAsync("CREATE INDEX areminder_startdate_idx ON areminder (startdate);");
await ExecQueryAsync("CREATE INDEX areminder_stopdate_idx ON areminder (stopdate);");
await ExecQueryAsync("CREATE INDEX areminder_tags ON areminder using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_areminder_userid ON areminder (userid);");
await ExecQueryAsync("CREATE INDEX idx_areminder_startdate ON areminder (startdate);");
await ExecQueryAsync("CREATE INDEX idx_areminder_stopdate ON areminder (stopdate);");
await ExecQueryAsync("CREATE INDEX idx_areminder_tags ON areminder using GIN(tags)");
//REVIEW
await ExecQueryAsync("CREATE TABLE areview (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null, " +
@@ -613,11 +611,11 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"duedate timestamp not null, completeddate timestamp null, completionnotes text, userid bigint not null references auser(id), " +
"assignedbyuserid bigint not null references auser(id), objecttype integer not null, objectid bigint not null)");
await ExecQueryAsync("CREATE INDEX areview_typeid_idx ON areview (objectid, objecttype );");
await ExecQueryAsync("CREATE INDEX areview_userid_idx ON areview (userid);");
await ExecQueryAsync("CREATE INDEX areview_duedate_idx ON areview (duedate);");
await ExecQueryAsync("CREATE INDEX areview_completeddate_idx ON areview (completeddate);");
await ExecQueryAsync("CREATE INDEX areview_tags ON areview using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_areview_objectid_objecttype ON areview (objectid, objecttype );");
await ExecQueryAsync("CREATE INDEX idx_areview_userid ON areview (userid);");
await ExecQueryAsync("CREATE INDEX idx_areview_duedate ON areview (duedate);");
await ExecQueryAsync("CREATE INDEX idx_areview_completeddate ON areview (completeddate);");
await ExecQueryAsync("CREATE INDEX idx_areview_tags ON areview using GIN(tags)");
//SERVICE BANK
@@ -636,7 +634,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"CONSTRAINT CHK_ServiceBank_Valid_Dates_Sequence CHECK(lastentrydate < entrydate), " +
"CONSTRAINT CHK_ServiceBank_Valid_Previous_Columns CHECK((lastentrydate IS NULL AND lastincidentsbalance IS NULL AND lastcurrencybalance IS NULL AND lasthoursbalance IS NULL) OR (lastentrydate IS NOT NULL AND lastincidentsbalance IS NOT NULL AND lastcurrencybalance IS NOT NULL AND lasthoursbalance IS NOT NULL)) " +
" )");
await ExecQueryAsync("CREATE INDEX aservicebank_typeid_idx ON aservicebank (objectid, objecttype );");
await ExecQueryAsync("CREATE INDEX idx_aservicebank_objectid_objecttype ON aservicebank (objectid, objecttype );");
@@ -646,8 +644,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"webaddress text, popupnotes text, billheadoffice bool, technotes text, accountnumber text, usesbanking bool, contractexpires timestamp null, " +
"phone1 text, phone2 text, phone3 text, phone4 text, phone5 text, emailaddress text, " +
"postaddress text, postcity text, postregion text, postcountry text, postcode text, address text, city text, region text, country text, latitude decimal(8,6), longitude decimal(9,6))");
await ExecQueryAsync("CREATE UNIQUE INDEX acustomer_name_id_idx ON acustomer (id, name);");
await ExecQueryAsync("CREATE INDEX acustomer_tags ON acustomer using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_acustomer_id_name ON acustomer (id, name);");
await ExecQueryAsync("CREATE INDEX idx_acustomer_tags ON acustomer using GIN(tags)");
await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (customerid) REFERENCES acustomer(id)");
@@ -655,13 +653,13 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
await ExecQueryAsync("CREATE TABLE acustomernote (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " +
"customerid bigint not null REFERENCES acustomer(id), userid bigint not null REFERENCES auser(id), " +
"notedate timestamp not null, notes text, tags varchar(255) ARRAY )");
await ExecQueryAsync("CREATE INDEX acustomernote_tags ON acustomernote using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_acustomernote_tags ON acustomernote using GIN(tags)");
//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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX acontract_name_id_idx ON acontract (id, name);");
await ExecQueryAsync("CREATE INDEX acontract_tags ON acontract using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_acontract_id_name ON acontract (id, name);");
await ExecQueryAsync("CREATE INDEX idx_acontract_tags ON acontract using GIN(tags)");
await ExecQueryAsync("ALTER TABLE acustomer add column contractid bigint null references acontract");
@@ -674,8 +672,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"postaddress text, postcity text, postregion text, postcountry text, postcode text, address text, city text, region text, country text, latitude decimal(8,6), longitude decimal(9,6)" +
" )");
await ExecQueryAsync("CREATE UNIQUE INDEX aheadoffice_name_id_idx ON aheadoffice (id, name);");
await ExecQueryAsync("CREATE INDEX aheadoffice_tags ON aheadoffice using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aheadoffice_id_name ON aheadoffice (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aheadoffice_tags ON aheadoffice using GIN(tags)");
await ExecQueryAsync("ALTER TABLE acustomer add column headofficeid bigint null references aheadoffice");
await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (headofficeid) REFERENCES aheadoffice(id)");
@@ -685,8 +683,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, webaddress text, popupnotes text, accountnumber text, " +
"contact text, contactnotes text, phone1 text, phone2 text, phone3 text, phone4 text, phone5 text, emailaddress text, " +
"postaddress text, postcity text, postregion text, postcountry text, postcode text, address text, city text, region text, country text, latitude decimal(8,6), longitude decimal(9,6))");
await ExecQueryAsync("CREATE UNIQUE INDEX avendor_name_id_idx ON avendor (id, name);");
await ExecQueryAsync("CREATE INDEX avendor_tags ON avendor using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_avendor_id_name ON avendor (id, name);");
await ExecQueryAsync("CREATE INDEX idx_avendor_tags ON avendor using GIN(tags)");
await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (vendorid) REFERENCES avendor(id)");
@@ -697,37 +695,37 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"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, trackserialnumber bool not null " +
" )");
await ExecQueryAsync("CREATE UNIQUE INDEX apart_name_id_idx ON apart (id, name);");
await ExecQueryAsync("CREATE INDEX apart_tags ON apart using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_apart_id_name ON apart (id, name);");
await ExecQueryAsync("CREATE INDEX idx_apart_tags ON apart using GIN(tags)");
//PARTASSEMBLY
await ExecQueryAsync("CREATE TABLE apartassembly (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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX apartassembly_name_id_idx ON apartassembly (id, name);");
await ExecQueryAsync("CREATE INDEX apartassembly_tags ON apartassembly using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_apartassembly_id_name ON apartassembly (id, name);");
await ExecQueryAsync("CREATE INDEX idx_apartassembly_tags ON apartassembly using GIN(tags)");
//PARTASSEMBLYITEM
await ExecQueryAsync("CREATE TABLE apartassemblyitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, partassemblyid bigint not null REFERENCES apartassembly on delete cascade, " +
"partid bigint not null REFERENCES apart, " +
"CONSTRAINT UNQ_PartAssemblyPart UNIQUE (partid, partassemblyid) " +//ensure no duplicate parts in the same assembly
")");
await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_part ON apartassemblyitem(partid)");
await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_partassembly ON apartassemblyitem(partassemblyid)");
await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_partid ON apartassemblyitem(partid)");
await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_partassemblyid ON apartassemblyitem(partassemblyid)");
//PROJECT
await ExecQueryAsync("CREATE TABLE aproject (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, " +
"datestarted timestamp null, datecompleted timestamp null, projectoverseerid bigint null references auser(id), accountnumber text)");
await ExecQueryAsync("CREATE UNIQUE INDEX aproject_name_id_idx ON aproject (id, name);");
await ExecQueryAsync("CREATE INDEX aproject_tags ON aproject using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aproject_id_name ON aproject (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aproject_tags ON aproject using GIN(tags)");
//PURCHASEORDER
//Note don't forget to update name fetcher stored procedure when change this to serial from name
await ExecQueryAsync("CREATE TABLE apurchaseorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint generated by default as identity not null, active bool not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
await ExecQueryAsync("CREATE UNIQUE INDEX apurchaseorder_serial_id_idx ON apurchaseorder (id, serial);");
await ExecQueryAsync("CREATE INDEX apurchaseorder_tags ON apurchaseorder using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_apurchaseorder_id_serial ON apurchaseorder (id, serial);");
await ExecQueryAsync("CREATE INDEX idx_apurchaseorder_tags ON apurchaseorder using GIN(tags)");
//UNITMODEL
await ExecQueryAsync("CREATE TABLE aunitmodel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text null, active bool not null, " +
@@ -735,8 +733,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"number text not null, vendorid bigint null references avendor(id), upc text null, lifetimewarranty bool not null, introduceddate timestamp null, " +
"discontinued bool not null, discontinueddate timestamp null, warrantylength integer null, warrantyterms text null, CONSTRAINT UNQ_UnitModelNumberVendorId UNIQUE (number, vendorid) " +
")");
await ExecQueryAsync("CREATE UNIQUE INDEX aunitmodel_name_id_idx ON aunitmodel (id, name);");
await ExecQueryAsync("CREATE INDEX aunitmodel_tags ON aunitmodel using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aunitmodel_id_name ON aunitmodel (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aunitmodel_tags ON aunitmodel using GIN(tags)");
//UNIT
@@ -750,8 +748,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"CONSTRAINT UNQ_UnitSerialModelId UNIQUE (serial, unitmodelid) " +
" )");
await ExecQueryAsync("CREATE UNIQUE INDEX aunit_serial_id_idx ON aunit (id, serial);");
await ExecQueryAsync("CREATE INDEX aunit_tags ON aunit using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aunit_id_serial ON aunit (id, serial);");
await ExecQueryAsync("CREATE INDEX idx_aunit_tags ON aunit using GIN(tags)");
//LOANUNIT
await ExecQueryAsync("CREATE TABLE aloanunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool not null, " +
@@ -759,8 +757,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"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 " +
")");
await ExecQueryAsync("CREATE UNIQUE INDEX aloanunit_name_id_idx ON aloanunit (id, name);");
await ExecQueryAsync("CREATE INDEX aloanunit_tags ON aloanunit using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aloanunit_id_name ON aloanunit (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aloanunit_tags ON aloanunit using GIN(tags)");
@@ -768,32 +766,32 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//WORKORDER
await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint generated by default as identity not null, active bool not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
await ExecQueryAsync("CREATE INDEX aworkorder_serial_id_idx ON aworkorder (id, serial);");//is this necessary or fruitful?
await ExecQueryAsync("CREATE INDEX aworkorder_tags ON aworkorder using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorder_id_serial ON aworkorder (id, serial);");//is this necessary or fruitful?
await ExecQueryAsync("CREATE INDEX idx_aworkorder_tags ON aworkorder using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderid bigint not null REFERENCES aworkorder (id), " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitem_name_id_idx ON aworkorderitem (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitem_tags ON aworkorderitem using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitem_tags ON aworkorderitem using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitemexpense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemexpense_name_id_idx ON aworkorderitemexpense (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitemexpense_tags ON aworkorderitemexpense using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitemexpense_tags ON aworkorderitemexpense using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitemlabor (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemlabor_name_id_idx ON aworkorderitemlabor (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitemlabor_tags ON aworkorderitemlabor using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitemlabor_tags ON aworkorderitemlabor using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitemloan (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemloan_name_id_idx ON aworkorderitemloan (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitemloan_tags ON aworkorderitemloan using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitemloan_tags ON aworkorderitemloan using GIN(tags)");
await ExecQueryAsync("ALTER TABLE aloanunit add column workorderitemloanid bigint null references aworkorderitemloan");
@@ -801,37 +799,37 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
await ExecQueryAsync("CREATE TABLE aworkorderitempart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
//await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitempart_name_id_idx ON aworkorderitempart (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitempart_tags ON aworkorderitempart using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitempart_tags ON aworkorderitempart using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitempartrequest (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitempartrequest_name_id_idx ON aworkorderitempartrequest (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitempartrequest_tags ON aworkorderitempartrequest using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitempartrequest_tags ON aworkorderitempartrequest using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitemscheduleduser (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemscheduleduser_name_id_idx ON aworkorderitemscheduleduser (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitemscheduleduser_tags ON aworkorderitemscheduleduser using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitemscheduleduser_tags ON aworkorderitemscheduleduser using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitemtask (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemtask_name_id_idx ON aworkorderitemtask (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitemtask_tags ON aworkorderitemtask using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitemtask_tags ON aworkorderitemtask using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitemtravel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemtravel_name_id_idx ON aworkorderitemtravel (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitemtravel_tags ON aworkorderitemtravel using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitemtravel_tags ON aworkorderitemtravel using GIN(tags)");
await ExecQueryAsync("CREATE TABLE aworkorderitemunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " +
"notes text, customfields text, tags varchar(255) ARRAY)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemunit_name_id_idx ON aworkorderitemunit (id, name);");
await ExecQueryAsync("CREATE INDEX aworkorderitemunit_tags ON aworkorderitemunit using GIN(tags)");
await ExecQueryAsync("CREATE INDEX idx_aworkorderitemunit_tags ON aworkorderitemunit using GIN(tags)");
//----------
@@ -840,63 +838,63 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
//WORKORDERTEMPLATE
await ExecQueryAsync("CREATE TABLE aworkordertemplate (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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX aworkordertemplate_name_id_idx ON aworkordertemplate (id, name);");
await ExecQueryAsync("CREATE INDEX aworkordertemplate_tags ON aworkordertemplate using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aworkordertemplate_id_name ON aworkordertemplate (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aworkordertemplate_tags ON aworkordertemplate using GIN(tags)");
await ExecQueryAsync("ALTER TABLE acustomer add column defaultservicetemplateid bigint null references aworkordertemplate");
//WORKORDERTEMPLATEITEM
await ExecQueryAsync("CREATE TABLE aworkordertemplateitem (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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX aworkordertemplateitem_name_id_idx ON aworkordertemplateitem (id, name);");
await ExecQueryAsync("CREATE INDEX aworkordertemplateitem_tags ON aworkordertemplateitem using GIN(tags)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aworkordertemplateitem_name_id_idx ON aworkordertemplateitem (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aworkordertemplateitem_tags ON aworkordertemplateitem using GIN(tags)");
//QUOTE
await ExecQueryAsync("CREATE TABLE aquote (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint generated by default as identity not null, active bool not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
await ExecQueryAsync("CREATE UNIQUE INDEX aquote_serial_id_idx ON aquote (id, serial);");//is this necessary or fruitful?
await ExecQueryAsync("CREATE INDEX aquote_tags ON aquote using GIN(tags)");
await ExecQueryAsync("CREATE UNIQUE INDEX idx_aquote_id_serial ON aquote (id, serial);");//is this necessary or fruitful?
await ExecQueryAsync("CREATE INDEX idx_aquote_tags ON aquote using GIN(tags)");
//QUOTEITEM
await ExecQueryAsync("CREATE TABLE aquoteitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteid bigint not null REFERENCES aquote (id), name text not null unique, active bool not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
await ExecQueryAsync("CREATE UNIQUE INDEX aquoteitem_name_id_idx ON aquoteitem (id, name);");
await ExecQueryAsync("CREATE INDEX aquoteitem_tags ON aquoteitem using GIN(tags)");
//await ExecQueryAsync("CREATE UNIQUE INDEX idx_aquoteitem_name_id_idx ON aquoteitem (id, name);");??
await ExecQueryAsync("CREATE INDEX idx_aquoteitem_tags ON aquoteitem using GIN(tags)");
//QUOTETEMPLATE
await ExecQueryAsync("CREATE TABLE aquotetemplate (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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX aquotetemplate_name_id_idx ON aquotetemplate (id, name);");
await ExecQueryAsync("CREATE INDEX aquotetemplate_tags ON aquotetemplate using GIN(tags)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aquotetemplate_name_id_idx ON aquotetemplate (id, name);");??
await ExecQueryAsync("CREATE INDEX idx_aquotetemplate_tags ON aquotetemplate using GIN(tags)");
//QUOTETEMPLATEITEM
await ExecQueryAsync("CREATE TABLE aquotetemplateitem (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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX aquotetemplateitem_name_id_idx ON aquotetemplateitem (id, name);");
await ExecQueryAsync("CREATE INDEX aquotetemplateitem_tags ON aquotetemplateitem using GIN(tags)");
// await ExecQueryAsync("CREATE UNIQUE INDEX aquotetemplateitem_name_id_idx ON aquotetemplateitem (id, name);");??
await ExecQueryAsync("CREATE INDEX idx_aquotetemplateitem_tags ON aquotetemplateitem using GIN(tags)");
//PM
await ExecQueryAsync("CREATE TABLE apm (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint generated by default as identity not null, active bool not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
await ExecQueryAsync("CREATE UNIQUE INDEX apm_serial_id_idx ON apm (id, serial);");//is this necessary or fruitful?
await ExecQueryAsync("CREATE INDEX apm_tags ON apm using GIN(tags)");
// await ExecQueryAsync("CREATE UNIQUE INDEX apm_serial_id_idx ON apm (id, serial);");//is this necessary or fruitful?
await ExecQueryAsync("CREATE INDEX idx_apm_tags ON apm using GIN(tags)");
//PMITEM
await ExecQueryAsync("CREATE TABLE apmitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmid bigint not null REFERENCES apm (id), name text not null unique, active bool not null, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY )");
await ExecQueryAsync("CREATE UNIQUE INDEX apmitem_name_id_idx ON apmitem (id, name);");
//await ExecQueryAsync("CREATE UNIQUE INDEX apmitem_name_id_idx ON apmitem (id, name);");??
await ExecQueryAsync("CREATE INDEX apmitem_tags ON apmitem using GIN(tags)");
//PMTEMPLATE
await ExecQueryAsync("CREATE TABLE apmtemplate (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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX apmtemplate_name_id_idx ON apmtemplate (id, name);");
await ExecQueryAsync("CREATE INDEX apmtemplate_tags ON apmtemplate using GIN(tags)");
// await ExecQueryAsync("CREATE UNIQUE INDEX apmtemplate_name_id_idx ON apmtemplate (id, name);");??
await ExecQueryAsync("CREATE INDEX idx_apmtemplate_tags ON apmtemplate using GIN(tags)");
//PMTEMPLATEITEM
await ExecQueryAsync("CREATE TABLE apmtemplateitem (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 )");
await ExecQueryAsync("CREATE UNIQUE INDEX apmtemplateitem_name_id_idx ON apmtemplateitem (id, name);");
await ExecQueryAsync("CREATE INDEX apmtemplateitem_tags ON apmtemplateitem using GIN(tags)");
//await ExecQueryAsync("CREATE UNIQUE INDEX apmtemplateitem_name_id_idx ON apmtemplateitem (id, name);");
await ExecQueryAsync("CREATE INDEX idx_apmtemplateitem_tags ON apmtemplateitem using GIN(tags)");
//CUSTOMERSERVICEREQUEST
@@ -906,8 +904,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"requestedbyuserid bigint not null references auser(id), customerreferencenumber text, status integer not null, priority integer not null " +
")");
await ExecQueryAsync("CREATE UNIQUE INDEX acustomerservicerequest_name_id_idx ON acustomerservicerequest (id, name);");
await ExecQueryAsync("CREATE INDEX acustomerservicerequest_tags ON acustomerservicerequest using GIN(tags)");
//await ExecQueryAsync("CREATE UNIQUE INDEX acustomerservicerequest_name_id_idx ON acustomerservicerequest (id, name);");
await ExecQueryAsync("CREATE INDEX idx_acustomerservicerequest_tags ON acustomerservicerequest using GIN(tags)");
await SetSchemaLevelAsync(++currentSchema);
}