This commit is contained in:
2021-03-10 21:49:09 +00:00
parent 715e35445b
commit 73ba204dc3
4 changed files with 24 additions and 27 deletions

2
.vscode/launch.json vendored
View File

@@ -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\\"

View File

@@ -138,18 +138,7 @@ namespace AyaNova.Biz
else
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
return null;
}
catch (Microsoft.EntityFrameworkCore.DbUpdateException ex)
{
if (ex.InnerException != null && ex.InnerException.Message.Contains("unq_unitmodelnumbervendorid"))
{
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "number", "Model number plus VendorId combination must be unique");
return null;
}
throw;
}
}
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
await SearchIndexAsync(putObject, false);
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, putObject.Tags, dbObject.Tags);

View File

@@ -715,6 +715,11 @@ namespace AyaNova.Biz
//TODO: Validation rules that require future other objects that aren't present yet:
/*
//MIGRATE_OUTSTANDING TODO: role changes when has things that require a role like notification subscriptions and others
//Don't allow to go from non scheduleable if there are any scheduled workorder items because
//it would damage the history
BrokenRules.Assert("UserType","User.Label.MustBeScheduleable","UserType",(mUserType==UserTypes.Schedulable) && (ScheduledUserCount(this.mID,false)>0));

View File

@@ -24,14 +24,14 @@ namespace AyaNova.Util
internal const long EXPECTED_COLUMN_COUNT = 788;
internal const long EXPECTED_INDEX_COUNT = 130;
internal const long EXPECTED_CHECK_CONSTRAINTS = 358;
internal const long EXPECTED_CHECK_CONSTRAINTS = 359;
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 78;
internal const long EXPECTED_VIEWS = 3;
internal const long EXPECTED_ROUTINES = 2;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
/*
@@ -643,13 +643,22 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
+ " )");
await ExecQueryAsync("CREATE INDEX idx_aservicebank_objectid_objecttype ON aservicebank (objectid, objecttype );");
//CONTRACT
await ExecQueryAsync("CREATE TABLE acontract (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, "
+ "responsetime INTERVAL NOT NULL, contractserviceratesonly BOOL NOT NULL, contracttravelratesonly BOOL NOT NULL, partsoverridepct DECIMAL(8,5) NOT NULL, partsoverridetype INTEGER NOT NULL, "
+ "serviceratesoverridepct DECIMAL(8,5) NOT NULL, serviceratesoverridetype INTEGER NOT NULL, travelratesoverridepct DECIMAL(8,5) NOT NULL, travelratesoverridetype INTEGER NOT NULL, "
+ "alertnotes text "
+ ")");
//CUSTOMER
await ExecQueryAsync("CREATE TABLE acustomer (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, billheadoffice BOOL, technotes TEXT, accountnumber TEXT, usesbanking BOOL, contractexpires TIMESTAMP NULL, "
+ "webaddress TEXT, popupnotes TEXT, billheadoffice BOOL, technotes TEXT, accountnumber TEXT, usesbanking BOOL, contractexpires TIMESTAMP NULL, contractid BIGINT NULL REFERENCES acontract(id), "
+ "phone1 TEXT, phone2 TEXT, phone3 TEXT, phone4 TEXT, phone5 TEXT, emailaddress TEXT, "
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6))");
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6), "
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL AND contractexpires IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
+ ")");
await ExecQueryAsync("ALTER TABLE auser ADD FOREIGN KEY (customerid) REFERENCES acustomer(id)");
@@ -658,14 +667,6 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
+ "customerid BIGINT NOT NULL REFERENCES acustomer(id), userid BIGINT NOT NULL REFERENCES auser(id), "
+ "notedate TIMESTAMP NOT NULL, notes TEXT, tags VARCHAR(255) ARRAY )");
//CONTRACT
await ExecQueryAsync("CREATE TABLE acontract (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, "
+ "responsetime INTERVAL NOT NULL, contractserviceratesonly BOOL NOT NULL, contracttravelratesonly BOOL NOT NULL, partsoverridepct DECIMAL(8,5) NOT NULL, partsoverridetype INTEGER NOT NULL, "
+ "serviceratesoverridepct DECIMAL(8,5) NOT NULL, serviceratesoverridetype INTEGER NOT NULL, travelratesoverridepct DECIMAL(8,5) NOT NULL, travelratesoverridetype INTEGER NOT NULL, "
+ "alertnotes text "
+ ")");
await ExecQueryAsync("ALTER TABLE acustomer ADD column contractid BIGINT NULL REFERENCES acontract");
//CONTRACTSERVICERATE
await ExecQueryAsync("CREATE TABLE acontractservicerate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, contractid BIGINT NOT NULL REFERENCES acontract ON DELETE CASCADE, "
@@ -695,7 +696,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
+ "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY,"
+ "webaddress TEXT, accountnumber TEXT, usesbanking BOOL, contractexpires TIMESTAMP NULL, contractid BIGINT NULL REFERENCES acontract(id), "
+ "phone1 TEXT, phone2 TEXT, phone3 TEXT, phone4 TEXT, phone5 TEXT, emailaddress TEXT, "
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6)"
+ "postaddress TEXT, postcity TEXT, postregion TEXT, postcountry TEXT, postcode TEXT, address TEXT, city TEXT, region TEXT, country TEXT, latitude DECIMAL(9,6), longitude DECIMAL(9,6), "
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL AND contractexpires IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
+ " )");
await ExecQueryAsync("ALTER TABLE acustomer ADD column headofficeid BIGINT NULL REFERENCES aheadoffice");
await ExecQueryAsync("ALTER TABLE auser ADD FOREIGN KEY (headofficeid) REFERENCES aheadoffice(id)");
@@ -805,7 +807,8 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
+ "overridemodelwarranty BOOL, warrantylength INTEGER NULL, warrantyterms TEXT NULL, contractid BIGINT NULL REFERENCES acontract, "
+ "contractexpires TIMESTAMP NULL, usesbanking BOOL, metered BOOL, lifetimewarranty BOOL, "
+ "text1 TEXT NULL, text2 TEXT NULL, text3 TEXT NULL, text4 TEXT NULL, address TEXT NULL, city TEXT NULL, region TEXT NULL, country TEXT NULL, latitude DECIMAL(9,6) NULL, longitude DECIMAL(9,6) NULL, "
+ "CONSTRAINT unq_unitserialmodelid UNIQUE (serial, unitmodelid) "
+ "CONSTRAINT unq_unitserialmodelid UNIQUE (serial, unitmodelid), "
+ "CONSTRAINT chk_contract_valid CHECK((contractid IS NULL AND contractexpires IS NULL) OR (contractid IS NOT NULL AND contractexpires IS NOT NULL)) "
+ " )");