This commit is contained in:
2020-02-27 16:05:02 +00:00
parent 060366e13d
commit 93908d1c35
4 changed files with 33 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ namespace AyaNova.Util
private const int DESIRED_SCHEMA_LEVEL = 9;
internal const long EXPECTED_COLUMN_COUNT = 98;
internal const long EXPECTED_INDEX_COUNT = 24;
internal const long EXPECTED_INDEX_COUNT = 25;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
@@ -208,7 +208,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, serial bigint not null," +
await ExecQueryAsync("CREATE TABLE awidget (id BIGSERIAL 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, customfields text, tags varchar(255) ARRAY)");

View File

@@ -115,6 +115,20 @@ namespace AyaNova.Util
return ret;
}
//Used to ensure a unique name generated by appending -nnn is within length requirements by splitting and chopping part of text to keep name
public static string UniqueNameBuilder(string oldName, long appendValue, int maxLength)
{
var appendString = "-" + appendValue.ToString();
string ret = oldName + appendString;
var diff = maxLength - ret.Length;
if (diff < 0)
{
ret = oldName.Substring(0, Math.Abs(diff)) + appendString;
}
return ret;
}
//used to trim an enum type down to only it's most relevant (rightmost) portion
public static string TrimTypeName(string str)
{