DE-INDEXIFICATION removed all tag and name indexes as found they were not being used at all for picklist queries which was why they were added

This commit is contained in:
2021-01-15 19:13:41 +00:00
parent 56f7a8c579
commit 50ad8142ee
3 changed files with 7 additions and 107 deletions

4
.vscode/launch.json vendored
View File

@@ -53,8 +53,8 @@
"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": "true",
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "huge",
"AYANOVA_SERVER_TEST_MODE": "false",
"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

@@ -36,6 +36,8 @@ namespace AyaNova.PickList
//BUILD THE QUERY
var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, tagSpecificQuery, includeInactive, preIds, variant);
log.LogInformation(q);
//RETURN OBJECTS
var ret = new List<NameIdActiveItem>();

View File

@@ -419,8 +419,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"dlkey text, dlkeyexpire timestamp, passwordresetcode text, passwordresetcodeexpire timestamp, usertype integer not null, employeenumber text, notes text, customerid bigint, " +
"headofficeid bigint, vendorid bigint, wiki text, customfields text, tags varchar(255) ARRAY)");
//Index for name fetching
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, " +
@@ -460,16 +458,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"startdate timestamp, enddate timestamp, dollaramount decimal(19,4), active bool not null, usertype int4, count integer," +
"notes text, userid bigint, wiki text, customfields text, tags varchar(255) ARRAY)");
//TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS
//exec("CREATE UNIQUE INDEX awidget_serial_idx ON awidget (serial);");
//Compound index for name fetching
await ExecQueryAsync("CREATE UNIQUE INDEX idx_awidget_id_name ON awidget (id, name);");
//Index for tags
await ExecQueryAsync("CREATE INDEX idx_awidget_tags ON AWIDGET using GIN(tags)");
await SetSchemaLevelAsync(++currentSchema);
}
@@ -572,28 +560,21 @@ $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 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 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 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 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, " +
@@ -603,7 +584,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
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, " +
@@ -615,7 +595,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
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
@@ -644,8 +623,6 @@ $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 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)");
@@ -653,14 +630,10 @@ $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 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 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");
@@ -672,8 +645,6 @@ $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 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)");
@@ -683,8 +654,6 @@ $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 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)");
@@ -695,37 +664,28 @@ $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 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 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_partid ON apartassemblyitem(partid)");
await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_partassemblyid 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 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 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, " +
@@ -733,8 +693,6 @@ $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 idx_aunitmodel_id_name ON aunitmodel (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aunitmodel_tags ON aunitmodel using GIN(tags)");
//UNIT
@@ -748,8 +706,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"CONSTRAINT UNQ_UnitSerialModelId UNIQUE (serial, unitmodelid) " +
" )");
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, " +
@@ -757,8 +713,6 @@ $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 idx_aloanunit_id_name ON aloanunit (id, name);");
await ExecQueryAsync("CREATE INDEX idx_aloanunit_tags ON aloanunit using GIN(tags)");
@@ -766,70 +720,38 @@ $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 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 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 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 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 idx_aworkorderitemloan_tags ON aworkorderitemloan using GIN(tags)");
await ExecQueryAsync("ALTER TABLE aloanunit add column workorderitemloanid bigint null references aworkorderitemloan");
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 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 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 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 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 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 idx_aworkorderitemunit_tags ON aworkorderitemunit using GIN(tags)");
//----------
@@ -838,64 +760,43 @@ $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 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 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 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 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 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 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 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 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 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 idx_apmtemplateitem_tags ON apmtemplateitem using GIN(tags)");
//CUSTOMERSERVICEREQUEST
await ExecQueryAsync("CREATE TABLE acustomerservicerequest (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null, " +
@@ -904,9 +805,6 @@ $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 idx_acustomerservicerequest_tags ON acustomerservicerequest using GIN(tags)");
await SetSchemaLevelAsync(++currentSchema);
}