This commit is contained in:
2020-12-29 00:53:40 +00:00
parent 0dc589283f
commit de9d096ed3
13 changed files with 824 additions and 18 deletions

View File

@@ -22,8 +22,8 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 15;
internal const long EXPECTED_COLUMN_COUNT = 560;
internal const long EXPECTED_INDEX_COUNT = 167;
internal const long EXPECTED_COLUMN_COUNT = 570;
internal const long EXPECTED_INDEX_COUNT = 171;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
@@ -315,8 +315,8 @@ END;
$BODY$;
");
//Name fetcher function
await ExecQueryAsync(@"
//Name fetcher function
await ExecQueryAsync(@"
CREATE OR REPLACE FUNCTION PUBLIC.AYGETNAME(IN AYOBJECTID bigint, IN AYOBJECTTYPE integer) RETURNS text AS $BODY$
DECLARE
aytable TEXT DEFAULT '';
@@ -388,6 +388,9 @@ BEGIN
when 59 then aytable = 'acustomernote';
when 60 then aytable = 'amemo';
when 61 then aytable = 'areview';
when 62 then aytable = 'aservicerate';
when 63 then aytable = 'atravelrate';
when 64 then aytable = 'ataxcode';
else
RETURN format('??PUBLIC.AYGETNAME-UNKNOWN_TYPE:%S',ayobjecttype);-- This should not happen unless dev forgot to update this
end case;
@@ -396,7 +399,7 @@ BEGIN
END;
$BODY$ LANGUAGE PLPGSQL STABLE");
//Usage: select created, textra, AYGETNAME(aevent.ayid, aevent.ayatype) as name from aevent order by created
//Usage: select created, textra, AYGETNAME(aevent.ayid, aevent.ayatype) as name from aevent order by created
//create translation text tables
@@ -565,7 +568,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
{
LogUpdateMessage(log);
//SERVICERATE
//SERVICERATE
await ExecQueryAsync("CREATE TABLE aservicerate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool, " +
"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)");
@@ -579,6 +582,13 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
await ExecQueryAsync("CREATE UNIQUE INDEX atravelrate_name_id_idx ON atravelrate (id, name);");
await ExecQueryAsync("CREATE INDEX 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, " +
"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)");
//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, " +

View File

@@ -367,6 +367,8 @@ namespace AyaNova.Util
await EraseTableAsync("aservicerate", conn);
await EraseTableAsync("atravelrate", conn);
await EraseTableAsync("ataxcode", conn);
//Delete from user options table first
using (var cmd = new Npgsql.NpgsqlCommand())