This commit is contained in:
2021-01-19 00:53:49 +00:00
parent 247c600e15
commit 4e15728207
6 changed files with 66 additions and 5 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 = 666;
internal const long EXPECTED_INDEX_COUNT = 115;
internal const long EXPECTED_COLUMN_COUNT = 669;
internal const long EXPECTED_INDEX_COUNT = 117;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
@@ -665,6 +665,10 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
"cost decimal(19,4) not null, retail decimal(19,4) not null, unitofmeasure text, upc text " +
" )");
//PARTSERIAL
await ExecQueryAsync("CREATE TABLE apartserial (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial text not null, "+
"partid bigint not null REFERENCES apart on delete cascade, CONSTRAINT UNQ_PartSerialPart UNIQUE (partid, serial) )");//ensure not duplicate partid/serial combo
//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 )");

View File

@@ -1522,7 +1522,7 @@ namespace AyaNova.Util
o.Retail = o.Cost * 1.2m;
o.UnitOfMeasure = "each";
//This seems wrong to do in a loop but is 4 times faster this way ?!?
using (AyContext ct = ServiceProviderProvider.DBContext)
@@ -1536,6 +1536,19 @@ namespace AyaNova.Util
log.LogError(err);
throw new System.Exception(err);
}
// 50% chance it has serial numbers
//MIGRATE_OUTSTANDING this is just temporary until inventory is coded fully
if (Fake.Random.Number() == 1)
{
var serialCount = Fake.Random.Number(1, 5);
for (int y = 0; y < serialCount; y++)
{
await ct.PartSerial.AddAsync(new PartSerial() { PartId = NewObject.Id, Serial = Fake.Finance.Account().ToString() + y.ToString() });
}
await ct.SaveChangesAsync();
}
}
}
}