This commit is contained in:
2018-10-08 20:07:38 +00:00
parent d58ede8fd3
commit 7df84c1ce8
9 changed files with 275 additions and 14 deletions

View File

@@ -0,0 +1,26 @@
using System;
using System.Threading.Tasks;
namespace AyaNova.Util
{
public class AutoId
{
private readonly object valueLock = new object();
private uint currentValue; //postgre bigint
public AutoId(uint initialValue)
{
currentValue = initialValue;
}
public uint GetNext()
{
lock (valueLock)
{
currentValue += 1;
if (currentValue == 0)
currentValue += 1;
return currentValue;
}
}
}
}

View File

@@ -22,8 +22,8 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 9;
internal const long EXPECTED_COLUMN_COUNT = 99;
internal const long EXPECTED_INDEX_COUNT = 22;
internal const long EXPECTED_COLUMN_COUNT = 100;
internal const long EXPECTED_INDEX_COUNT = 23;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::PrepareDatabaseForSeeding WHEN NEW TABLES ADDED!!!!
@@ -152,7 +152,7 @@ namespace AyaNova.Util
exec("CREATE TABLE alocaleitem (id BIGSERIAL PRIMARY KEY, localeid bigint not null REFERENCES alocale (id), key text not null, display text not null)");
//LOOKAT: this is for what exactly??
// exec("CREATE INDEX alocaleitem_localeid_key_idx ON alocaleitem (localeid,key)");
// exec("CREATE INDEX alocaleitem_localeid_key_idx ON alocaleitem (localeid,key)");
//This seems more appropriate
exec("CREATE INDEX alocaleitem_localeid_key_display_idx ON alocaleitem (localeid,key, display)");
@@ -201,9 +201,13 @@ namespace AyaNova.Util
//Add widget table
//id, text, longtext, boolean, currency,
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, " +
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, serial bigint not null," +
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, notes text)");
//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
exec("CREATE UNIQUE INDEX awidget_name_id_idx ON awidget (id, name);");

View File

@@ -30,6 +30,10 @@ namespace AyaNova.Util
ApiServerState.ServerState wasServerState = apiServerState.GetState();
string wasReason = apiServerState.Reason;
//START SERIAL NUMBER GENERATORS
if (ServerBootConfig.WIDGET_SERIAL == null)
ServerBootConfig.WIDGET_SERIAL = new AutoId(0);
try
{
log.LogInformation("SEEDER: Seed data level - " + slevel.ToString());

View File

@@ -12,6 +12,10 @@ namespace AyaNova.Util
internal static class ServerBootConfig
{
//TEST AUTOID
//Get the highest id number issued previously and start the auto-id at that level
internal static AutoId WIDGET_SERIAL { get; set; }
//Diagnostic static values used during development, may not be related to config at all, this is just a convenient class to put them in
#if (DEBUG)