From 07b3061fb4634e4677c89dff474136b134082a43 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 7 Sep 2021 19:16:40 +0000 Subject: [PATCH] --- server/AyaNova/biz/ReportBiz.cs | 3 ++- server/AyaNova/util/AySchema.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/AyaNova/biz/ReportBiz.cs b/server/AyaNova/biz/ReportBiz.cs index 97ab3721..eea64854 100644 --- a/server/AyaNova/biz/ReportBiz.cs +++ b/server/AyaNova/biz/ReportBiz.cs @@ -303,7 +303,8 @@ namespace AyaNova.Biz if (!PropertyHasErrors("Name")) { //Use Any command is efficient way to check existance, it doesn't return the record, just a true or false - if (await ct.Report.AnyAsync(z => z.Name == proposedObj.Name && z.Id != proposedObj.Id)) + //NOTE: unlike other objects reports can have the same name as long as the type differs + if (await ct.Report.AnyAsync(z => z.Name == proposedObj.Name && z.AType==proposedObj.AType && z.Id != proposedObj.Id)) { AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name"); } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 41b7d4ed..53cb52ff 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -1175,10 +1175,10 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); + "large bytea, largetype TEXT, medium bytea, mediumtype TEXT, small bytea, smalltype TEXT)"); //REPORTS - await ExecQueryAsync("CREATE TABLE areport (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL UNIQUE, active BOOL NOT NULL, " + await ExecQueryAsync("CREATE TABLE areport (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, active BOOL NOT NULL, " + "notes TEXT, roles INTEGER NOT NULL, atype INTEGER NOT NULL, includewoitemdescendants BOOL, template TEXT, style TEXT, jsprerender TEXT, jshelpers TEXT, rendertype INTEGER NOT NULL, " + "headertemplate TEXT, footertemplate TEXT, displayheaderfooter BOOL, paperformat INTEGER NOT NULL, landscape BOOL, marginoptionsbottom TEXT, " - + "marginoptionsleft TEXT, marginoptionsright TEXT, marginoptionstop TEXT, pageranges TEXT, prefercsspagesize BOOL, printbackground BOOL, scale DECIMAL(8,5) )"); + + "marginoptionsleft TEXT, marginoptionsright TEXT, marginoptionstop TEXT, pageranges TEXT, prefercsspagesize BOOL, printbackground BOOL, scale DECIMAL(8,5), UNIQUE(name,atype))"); //Global customer default workorder report default await ExecQueryAsync("ALTER TABLE aglobalbizsettings ADD column customerdefaultworkorderreportid BIGINT REFERENCES areport(id) ");