From 063631665126774846b2f8a729d7d796547b2fd6 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 14 Jan 2021 15:37:08 +0000 Subject: [PATCH] --- server/AyaNova/biz/PartAssemblyBiz.cs | 30 +++++++++++++++++++++++++++ server/AyaNova/util/AySchema.cs | 10 +++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/server/AyaNova/biz/PartAssemblyBiz.cs b/server/AyaNova/biz/PartAssemblyBiz.cs index 6841127f..c067dc08 100644 --- a/server/AyaNova/biz/PartAssemblyBiz.cs +++ b/server/AyaNova/biz/PartAssemblyBiz.cs @@ -60,6 +60,36 @@ namespace AyaNova.Biz } } + /* + static void Main(string[] args) + { + using (var dbContext = new DbParentChild()) + { + var parent = new Parent + { + FirstName = "Joe", + LastName = "Smith" + }; + + parent.Children.Add( + new Child + { + FirstName = "LittleJoe", + LastName = "Smith" + }); + parent.Children.Add( + new Child + { + FirstName = "Anne", + LastName = "Smith" + }); + + dbContext.Add(parent); + dbContext.SaveChanges(); + } + } + */ + //////////////////////////////////////////////////////////////////////////////////////////////// //DUPLICATE // diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index d9fa230b..0887b335 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -23,7 +23,7 @@ namespace AyaNova.Util private const int DESIRED_SCHEMA_LEVEL = 15; internal const long EXPECTED_COLUMN_COUNT = 667; - internal const long EXPECTED_INDEX_COUNT = 185; + internal const long EXPECTED_INDEX_COUNT = 186; //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! @@ -679,7 +679,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("ALTER TABLE acustomer add column headofficeid bigint null references aheadoffice"); await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (headofficeid) REFERENCES aheadoffice(id)"); - + //VENDOR await ExecQueryAsync("CREATE TABLE avendor (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, webaddress text, popupnotes text, accountnumber text, " + @@ -693,7 +693,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); //PART await ExecQueryAsync("CREATE TABLE apart (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text, active bool not null, " + "notes text, wiki text, customfields text, tags varchar(255) ARRAY, " + - "partnumber text not null unique, popupnotes text, manufacturerid bigint REFERENCES avendor, manufacturernumber text, "+ + "partnumber text not null unique, popupnotes text, manufacturerid bigint REFERENCES avendor, manufacturernumber text, " + "wholesalerid bigint REFERENCES avendor, wholesalernumber text, alternativewholesalerid bigint REFERENCES avendor, alternativewholesalernumber text, " + "cost decimal(19,4) not null, retail decimal(19,4) not null, unitofmeasure text, upc text, trackserialnumber bool not null " + " )"); @@ -708,7 +708,9 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); //PARTASSEMBLYITEM await ExecQueryAsync("CREATE TABLE apartassemblyitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, partassemblyid bigint not null REFERENCES apartassembly on delete cascade, " + - "partid bigint not null REFERENCES apart)"); + "partid bigint not null REFERENCES apart, " + + "CONSTRAINT UNQ_PartAssemblyPart UNIQUE (partid, partassemblyid) " +//ensure no duplicate parts in the same assembly + ")"); await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_part ON apartassemblyitem(partid)"); await ExecQueryAsync("CREATE INDEX idx_apartassemblyitem_partassembly ON apartassemblyitem(partassemblyid)");