From 1b3fdfeca97574f614de5a509c34ac95389c4511 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 14 May 2020 14:22:30 +0000 Subject: [PATCH] --- server/AyaNova/biz/WidgetBiz.cs | 8 ++++---- server/AyaNova/models/AyContext.cs | 3 +++ server/AyaNova/util/AySchema.cs | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index 174ea52f..f1df132c 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -43,7 +43,7 @@ namespace AyaNova.Biz return null; else { - newObject.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext(); + // newObject.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext(); newObject.Tags = TagUtil.NormalizeTags(newObject.Tags); newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields); await ct.Widget.AddAsync(newObject); @@ -67,7 +67,7 @@ namespace AyaNova.Biz return null; } Widget newObject = new Widget(); - CopyObject.Copy(dbObject, newObject, "Wiki"); + CopyObject.Copy(dbObject, newObject, "Wiki,Serial"); string newUniqueName = string.Empty; bool NotUnique = true; long l = 1; @@ -77,7 +77,7 @@ namespace AyaNova.Biz NotUnique = await ct.Widget.AnyAsync(m => m.Name == newUniqueName); } while (NotUnique); newObject.Name = newUniqueName; - newObject.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext(); + //newObject.Serial = ServerBootConfig.WIDGET_SERIAL.GetNext(); newObject.Id = 0; newObject.Concurrency = 0; await ct.Widget.AddAsync(newObject); @@ -112,7 +112,7 @@ namespace AyaNova.Biz } Widget SnapshotOfOriginalDBObj = new Widget(); CopyObject.Copy(dbObject, SnapshotOfOriginalDBObj); - CopyObject.Copy(putObject, dbObject, "Id,Serial"); + CopyObject.Copy(putObject, dbObject, "Id");//can update serial dbObject.Tags = TagUtil.NormalizeTags(dbObject.Tags); dbObject.CustomFields = JsonUtil.CompactJson(dbObject.CustomFields); ct.Entry(dbObject).OriginalValues["Concurrency"] = putObject.Concurrency; diff --git a/server/AyaNova/models/AyContext.cs b/server/AyaNova/models/AyContext.cs index 4ebcc911..b498418d 100644 --- a/server/AyaNova/models/AyContext.cs +++ b/server/AyaNova/models/AyContext.cs @@ -137,6 +137,9 @@ namespace AyaNova.Models .HasForeignKey(b => b.UserId) .OnDelete(DeleteBehavior.NoAction); + + modelBuilder.Entity().Property(z => z.Serial).UseIdentityByDefaultColumn(); + // //Workorder // modelBuilder.Entity() // .HasOne(p => p.WorkOrder) diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 08c2a046..89b7f239 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -210,7 +210,7 @@ namespace AyaNova.Util //Add widget table //id, text, longtext, boolean, currency, - await ExecQueryAsync("CREATE TABLE awidget (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, serial bigint not null," + + await ExecQueryAsync("CREATE TABLE awidget (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, serial bigint generated by default as identity not null," + "startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, usertype int4, count integer," + "notes text, userid bigint null, wiki text null, customfields text, tags varchar(255) ARRAY)"); @@ -384,7 +384,7 @@ namespace AyaNova.Util //---------- //WORKORDER - await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint not null, active bool, " + + await ExecQueryAsync("CREATE TABLE aworkorder (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, serial bigint generated by default as identity not null, active bool, " + "notes text NULL, wiki text null, customfields text NULL, tags varchar(255) ARRAY NULL)"); await ExecQueryAsync("CREATE INDEX aworkorder_serial_id_idx ON aworkorder (id, serial);");//is this necessary or fruitful? await ExecQueryAsync("CREATE INDEX aworkorder_tags ON aworkorder using GIN(tags)");