diff --git a/.vscode/launch.json b/.vscode/launch.json index 0e2049e9..8fd97968 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,7 +53,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "false", + "AYANOVA_SERVER_TEST_MODE": "true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" diff --git a/server/AyaNova/models/PartAssembly.cs b/server/AyaNova/models/PartAssembly.cs index b0422f05..1abb1df5 100644 --- a/server/AyaNova/models/PartAssembly.cs +++ b/server/AyaNova/models/PartAssembly.cs @@ -7,8 +7,7 @@ using Newtonsoft.Json; namespace AyaNova.Models { - //NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal, - //otherwise the server will call it an invalid record if the field isn't sent from client + //https://stackoverflow.com/questions/46517584/how-to-add-a-parent-record-with-its-children-records-in-ef-core#46615455 public class PartAssembly : ICoreBizObjectModel { @@ -21,12 +20,8 @@ namespace AyaNova.Models public string Notes { get; set; } public string Wiki { get; set; } public string CustomFields { get; set; } - public List Tags { get; set; } - - public PartAssembly() - { - Tags = new List(); - } + public List Tags { get; set; } = new List(); + public List Items { get; set; } = new List(); [NotMapped, JsonIgnore] public AyaType AyaType { get => AyaType.PartAssembly; } diff --git a/server/AyaNova/models/PartAssemblyItem.cs b/server/AyaNova/models/PartAssemblyItem.cs index 4a8b0b59..098230a0 100644 --- a/server/AyaNova/models/PartAssemblyItem.cs +++ b/server/AyaNova/models/PartAssemblyItem.cs @@ -7,28 +7,16 @@ using Newtonsoft.Json; namespace AyaNova.Models { - //NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal, - //otherwise the server will call it an invalid record if the field isn't sent from client - + //https://stackoverflow.com/questions/46517584/how-to-add-a-parent-record-with-its-children-records-in-ef-core#46615455 public class PartAssemblyItem { public long Id { get; set; } public uint Concurrency { get; set; } - //Principle [Required] - public long PartAssemblyId { get; set; }//fk - // public PartAssembly PartAssembly { get; set; } //FOR NOW COMMENTINGH OUT THESE CONVENIENCE REFERENCES UNCOMMENT IF NEED LATER COULD BE YAGNI - - public long PartId { get; set; }//fk - //public Part Part { get; set; } - - public PartAssemblyItem() - { - - } - - + public long PartAssemblyId { get; set; } + public PartAssembly PartAssembly { get; set; } + public long PartId { get; set; } }//eoc diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 24af8b7c..3d9950cc 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -707,7 +707,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("CREATE INDEX apartassembly_tags ON apartassembly using GIN(tags)"); //PARTASSEMBLYITEM - await ExecQueryAsync("CREATE TABLE apartassemblyitem (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, partassemblyid bigint not null REFERENCES apartassembly, " + + 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)"); //PROJECT