From 231705e294f156311f9aed8f9e3fe72126ef7240 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 14 May 2020 14:04:02 +0000 Subject: [PATCH] switched to modern serial method for tables --- devdocs/todo.txt | 4 +- server/AyaNova/util/AySchema.cs | 90 ++++++++++++++++----------------- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 44225414..4d476479 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -1,7 +1,8 @@ PRIORITY - ALWAYS Lowest level stuff first =-=-=-=- -todo: add query fail logging to datalist just like done with picklist so in production can catch mysterious problems more easily +todo: switch to Identity column from serial column as it's the proper way to do autoid in postgres now + todo: AUTO ID GENERATOR change to a dedicated spot in global rather than inferring as it is not right practically for reasons Get the auto-id most recent values at boot time @@ -11,6 +12,7 @@ todo: AUTO ID GENERATOR Instead have central location for storing serial numbers (perhaps one per table type for concurrency efficieny? Though it's a pretty fast operation.) Do not put in shared object though, i.e. global settings or something because it's going to be it's own thing and require efficient access. Maybe this is a case for a stored procedure? + todo: change trial detection route that client first hits - make it a different controller and renamed to something like server ping or "hello" or something friendly and useful - maybe the route that gets Notifications diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 0995b289..08c2a046 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -143,7 +143,7 @@ namespace AyaNova.Util "searchcasesensitiveonly bool default false)"); //create aevent biz event log table - await ExecQueryAsync("CREATE TABLE aevent (id BIGSERIAL PRIMARY KEY, created timestamp not null, userid bigint not null," + + 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, aytype 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, aytype);"); @@ -151,17 +151,17 @@ namespace AyaNova.Util //SEARCH TABLES - await ExecQueryAsync("CREATE TABLE asearchdictionary (id BIGSERIAL PRIMARY KEY, word varchar(255) not null)"); + await ExecQueryAsync("CREATE TABLE asearchdictionary (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, word varchar(255) not null)"); //Search dictionary words must be unique await ExecQueryAsync("CREATE UNIQUE INDEX asearchdictionary_word_idx ON asearchdictionary (word);"); - await ExecQueryAsync("CREATE TABLE asearchkey (id BIGSERIAL PRIMARY KEY, wordid bigint not null REFERENCES asearchdictionary (id), objectid bigint not null, objecttype integer not null)"); + await ExecQueryAsync("CREATE TABLE asearchkey (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, wordid bigint not null REFERENCES asearchdictionary (id), objectid bigint not null, objecttype integer not null)"); //todo: I think there is a missing index here, need to look at the search query section again as it was changed several times from the original schema creation //create translation text tables - await ExecQueryAsync("CREATE TABLE atranslation (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, stock bool, cjkindex bool default false)"); + await ExecQueryAsync("CREATE TABLE atranslation (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null, stock bool, cjkindex bool default false)"); //LOOKAT: I don't think this is doing anything: //exec("CREATE UNIQUE INDEX atranslation_name_idx ON atranslation (name)"); - await ExecQueryAsync("CREATE TABLE atranslationitem (id BIGSERIAL PRIMARY KEY, translationid bigint not null REFERENCES atranslation (id), key text not null, display text not null)"); + 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)"); await ExecQueryAsync("CREATE INDEX atranslationitem_translationid_key_display_idx ON atranslationitem (translationid,key, display)"); //Load the default TRANSLATIONS @@ -169,7 +169,7 @@ namespace AyaNova.Util //Add user table - await ExecQueryAsync("CREATE TABLE auser (id BIGSERIAL PRIMARY KEY, active bool not null, name varchar(255) not null unique, " + + await ExecQueryAsync("CREATE TABLE auser (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, active bool not null, name varchar(255) not null unique, " + "login text not null unique, password text not null, salt text not null, roles integer not null, currentauthtoken text, " + "dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber varchar(255), notes text, customerid bigint, " + "headofficeid bigint, subvendorid bigint, wiki text null, customfields text, tags varchar(255) ARRAY)"); @@ -178,7 +178,7 @@ namespace AyaNova.Util await ExecQueryAsync("CREATE UNIQUE INDEX auser_name_id_idx ON auser (id, name);"); //Add user options table - await ExecQueryAsync("CREATE TABLE auseroptions (id BIGSERIAL PRIMARY KEY, " + + await ExecQueryAsync("CREATE TABLE auseroptions (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + "userid bigint not null, translationid bigint not null REFERENCES atranslation (id), languageoverride text, timezoneoverride text, currencyname text, hour12 bool not null, emailaddress text, uicolor varchar(12) not null default '#000000')"); @@ -196,7 +196,7 @@ namespace AyaNova.Util LogUpdateMessage(log); //Add user table - await ExecQueryAsync("CREATE TABLE alicense (id BIGSERIAL PRIMARY KEY, dbid uuid, key text not null)"); + await ExecQueryAsync("CREATE TABLE alicense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, dbid uuid, key text not null)"); await SetSchemaLevelAsync(++currentSchema); } @@ -210,7 +210,7 @@ namespace AyaNova.Util //Add widget table //id, text, longtext, boolean, currency, - await ExecQueryAsync("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, serial bigint not null," + + await ExecQueryAsync("CREATE TABLE awidget (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, serial bigint not null," + "startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, usertype int4, count integer," + "notes text, userid bigint null, wiki text null, customfields text, tags varchar(255) ARRAY)"); @@ -234,7 +234,7 @@ namespace AyaNova.Util { LogUpdateMessage(log); - await ExecQueryAsync("CREATE TABLE afileattachment (id BIGSERIAL PRIMARY KEY, " + + await ExecQueryAsync("CREATE TABLE afileattachment (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + "attachtoobjectid bigint not null, attachtoobjecttype integer not null, " + "storedfilename text not null, displayfilename text not null, contenttype text, lastmodified timestamp not null, notes text)"); @@ -272,7 +272,7 @@ namespace AyaNova.Util { LogUpdateMessage(log); - await ExecQueryAsync("CREATE TABLE adatalistview (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null unique, public bool not null," + + await ExecQueryAsync("CREATE TABLE adatalistview (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, userId bigint not null, name varchar(255) not null unique, public bool not null," + "listkey varchar(255) not null, listview text)"); await SetSchemaLevelAsync(++currentSchema); @@ -284,7 +284,7 @@ namespace AyaNova.Util if (currentSchema < 8) { LogUpdateMessage(log); - await ExecQueryAsync("CREATE TABLE atag (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, refcount bigint not null)"); + await ExecQueryAsync("CREATE TABLE atag (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, refcount bigint not null)"); await SetSchemaLevelAsync(++currentSchema); } @@ -296,7 +296,7 @@ namespace AyaNova.Util { LogUpdateMessage(log); - await ExecQueryAsync("CREATE TABLE aformcustom (id BIGSERIAL PRIMARY KEY, " + + await ExecQueryAsync("CREATE TABLE aformcustom (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + "formkey varchar(255) not null, template text, UNIQUE(formkey))"); await SetSchemaLevelAsync(++currentSchema); } @@ -323,128 +323,128 @@ namespace AyaNova.Util LogUpdateMessage(log); //CUSTOMER - await ExecQueryAsync("CREATE TABLE acustomer (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE acustomer (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX acustomer_name_id_idx ON acustomer (id, name);"); await ExecQueryAsync("CREATE INDEX acustomer_tags ON acustomer using GIN(tags)"); //CONTRACT - await ExecQueryAsync("CREATE TABLE acontract (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE acontract (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX acontract_name_id_idx ON acontract (id, name);"); await ExecQueryAsync("CREATE INDEX acontract_tags ON acontract using GIN(tags)"); //HEADOFFICE - await ExecQueryAsync("CREATE TABLE aheadoffice (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aheadoffice (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aheadoffice_name_id_idx ON aheadoffice (id, name);"); await ExecQueryAsync("CREATE INDEX aheadoffice_tags ON aheadoffice using GIN(tags)"); //LOANUNIT - await ExecQueryAsync("CREATE TABLE aloanunit (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aloanunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY 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)"); //PART - await ExecQueryAsync("CREATE TABLE apart (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE apart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY 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)"); //PROJECT - await ExecQueryAsync("CREATE TABLE aproject (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aproject (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aproject_name_id_idx ON aproject (id, name);"); await ExecQueryAsync("CREATE INDEX aproject_tags ON aproject using GIN(tags)"); //PURCHASEORDER - await ExecQueryAsync("CREATE TABLE apurchaseorder (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE apurchaseorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX apurchaseorder_name_id_idx ON apurchaseorder (id, name);"); await ExecQueryAsync("CREATE INDEX apurchaseorder_tags ON apurchaseorder using GIN(tags)"); //UNIT - await ExecQueryAsync("CREATE TABLE aunit (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aunit_name_id_idx ON aunit (id, name);"); await ExecQueryAsync("CREATE INDEX aunit_tags ON aunit using GIN(tags)"); //UNITMODEL - await ExecQueryAsync("CREATE TABLE aunitmodel (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aunitmodel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aunitmodel_name_id_idx ON aunitmodel (id, name);"); await ExecQueryAsync("CREATE INDEX aunitmodel_tags ON aunitmodel using GIN(tags)"); //VENDOR - await ExecQueryAsync("CREATE TABLE avendor (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE avendor (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX avendor_name_id_idx ON avendor (id, name);"); await ExecQueryAsync("CREATE INDEX avendor_tags ON avendor using GIN(tags)"); //---------- //WORKORDER - await ExecQueryAsync("CREATE TABLE aworkorder (id BIGSERIAL PRIMARY KEY, serial bigint not null, active bool, " + + await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint not null, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); 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 TABLE aworkorderitem (id BIGSERIAL PRIMARY KEY, workorderid bigint not null REFERENCES aworkorder (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderid bigint not null REFERENCES aworkorder (id), " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitemexpense (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitemexpense (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitemlabor (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitemlabor (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitemloan (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitemloan (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitempart (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitempart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); //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 TABLE aworkorderitempartrequest (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitempartrequest (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitemscheduleduser (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitemscheduleduser (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitemtask (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitemtask (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitemtravel (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitemtravel (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // 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 TABLE aworkorderitemunit (id BIGSERIAL PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + + await ExecQueryAsync("CREATE TABLE aworkorderitemunit (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, workorderitemid bigint not null REFERENCES aworkorderitem (id), " + "notes text NULL, customfields text NULL, tags varchar(255) ARRAY NULL)"); // await ExecQueryAsync("CREATE UNIQUE INDEX aworkorderitemunit_name_id_idx ON aworkorderitemunit (id, name);"); await ExecQueryAsync("CREATE INDEX aworkorderitemunit_tags ON aworkorderitemunit using GIN(tags)"); @@ -454,61 +454,61 @@ namespace AyaNova.Util //WORKORDERTEMPLATE - await ExecQueryAsync("CREATE TABLE aworkordertemplate (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aworkordertemplate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aworkordertemplate_name_id_idx ON aworkordertemplate (id, name);"); await ExecQueryAsync("CREATE INDEX aworkordertemplate_tags ON aworkordertemplate using GIN(tags)"); //WORKORDERTEMPLATEITEM - await ExecQueryAsync("CREATE TABLE aworkordertemplateitem (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aworkordertemplateitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aworkordertemplateitem_name_id_idx ON aworkordertemplateitem (id, name);"); await ExecQueryAsync("CREATE INDEX aworkordertemplateitem_tags ON aworkordertemplateitem using GIN(tags)"); //QUOTE - await ExecQueryAsync("CREATE TABLE aquote (id BIGSERIAL PRIMARY KEY, serial bigint not null, active bool, " + + await ExecQueryAsync("CREATE TABLE aquote (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint not null, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); 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)"); //QUOTEITEM - await ExecQueryAsync("CREATE TABLE aquoteitem (id BIGSERIAL PRIMARY KEY, quoteid bigint not null REFERENCES aquote (id), name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aquoteitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, quoteid bigint not null REFERENCES aquote (id), name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aquoteitem_name_id_idx ON aquoteitem (id, name);"); await ExecQueryAsync("CREATE INDEX aquoteitem_tags ON aquoteitem using GIN(tags)"); //QUOTETEMPLATE - await ExecQueryAsync("CREATE TABLE aquotetemplate (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aquotetemplate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aquotetemplate_name_id_idx ON aquotetemplate (id, name);"); await ExecQueryAsync("CREATE INDEX aquotetemplate_tags ON aquotetemplate using GIN(tags)"); //QUOTETEMPLATEITEM - await ExecQueryAsync("CREATE TABLE aquotetemplateitem (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE aquotetemplateitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX aquotetemplateitem_name_id_idx ON aquotetemplateitem (id, name);"); await ExecQueryAsync("CREATE INDEX aquotetemplateitem_tags ON aquotetemplateitem using GIN(tags)"); //PM - await ExecQueryAsync("CREATE TABLE apm (id BIGSERIAL PRIMARY KEY, serial bigint not null, active bool, " + + await ExecQueryAsync("CREATE TABLE apm (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint not null, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); 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)"); //PMITEM - await ExecQueryAsync("CREATE TABLE apmitem (id BIGSERIAL PRIMARY KEY, pmid bigint not null REFERENCES apm (id), name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE apmitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, pmid bigint not null REFERENCES apm (id), name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); 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 BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE apmtemplate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX apmtemplate_name_id_idx ON apmtemplate (id, name);"); await ExecQueryAsync("CREATE INDEX apmtemplate_tags ON apmtemplate using GIN(tags)"); //PMTEMPLATEITEM - await ExecQueryAsync("CREATE TABLE apmtemplateitem (id BIGSERIAL PRIMARY KEY, name varchar(255) not null unique, active bool, " + + await ExecQueryAsync("CREATE TABLE apmtemplateitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE UNIQUE INDEX apmtemplateitem_name_id_idx ON apmtemplateitem (id, name);"); await ExecQueryAsync("CREATE INDEX apmtemplateitem_tags ON apmtemplateitem using GIN(tags)"); @@ -525,7 +525,7 @@ namespace AyaNova.Util // { // LogUpdateMessage(log); - // await ExecQueryAsync("CREATE TABLE awikipage (id BIGSERIAL PRIMARY KEY, " + + // await ExecQueryAsync("CREATE TABLE awikipage (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " + // "objectid bigint not null, objecttype integer not null, " + // "content text)");