From a06996b6bc9f9839e6162f6765dfddda994b69e3 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Wed, 8 May 2024 12:28:03 +0100 Subject: [PATCH] Backbone-specific addresses (#570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add 100 char-long identityAddresses * chore: add missing config * chore: fix erroneous migrations * feat: add 100 char-long identityAddresses on SqlServer * chore: fix erroneous migrations' name * chore: fix erroneous migrations' name * chore: attempt to remove identity assertions from transport tests * chore: fix sed * chore: fix erroneous migrations' name * chore: use backbone-specific-addresses branch of transport tests * chore: branch → ref * chore: fix branch name * chore: backbone sln merge * chore: remove realm, change url to prod.enmeshed.eu where applicable * chore: fix unit tests after removing realm from identity * chore: remove AddressPrefix from config files * chore: remove AddressPrefix from config files * chore: fix formatting * chore: remove second needless migration * fix: remove old configuration and update messages to use InstanceUrl, from configuration * chore: move migration order hopefully this fixes the pipeline for now. However, this must be fixed later * feat: implement new IdentityAddress generation algorithm * chore: reformat * chore: simplify isValid * feat: change address length to 80 * chore: fix migration name * chore: fix migration name * chore: fix old 100 to 80 chars * chore: trigger pipeline * fix: pipeline test file * fix: missing defaultschema for migrations * fix: missing defaultschema for migrations * fix: max length set to 100 * chore: add InstanceUrl to test appsettings * chore: transport tests should still use the backbone-specific-addresses branch * chore: add InstanceUrl to test appsettings for event handler * fix: bad feature/backbone-specific-addresses branch name * fix: 100 → 80 chars * chore: remove out-of-date migrations * feat: Identity80 migrations for relationships module * chore: more restrictive regex. usage of return value instead of relying on exceptions * chore: fix migration file names * fix: exception thrown when address does not match the regex * chore: identitySpecificPart must be a hex representation of bytes * refactor: turn regex into a compiled one * chorte: remove unused pattern * chore: use named regex groups * chore: extract CHECKSUM_LENGTH, create addressWithoutChecksumregex group * chore: optimize regex * refactor: rename variable --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Timo Notheisen <65653426+tnotheis@users.noreply.github.com> Co-authored-by: Timo Notheisen --- .github/workflows/test.yml | 4 +- AdminApi/src/AdminApi/appsettings.json | 2 +- .../src/AdminApi/appsettings.override.json | 1 - Backbone.sln.DotSettings | 3 +- .../ValueObjects/IdentityAddress.cs | 59 +- .../UnitTestTools/Data/TestDataGenerator.cs | 2 +- .../IdentityAddressTests.cs | 90 +- .../appsettings.json | 12 + ConsumerApi/appsettings.json | 4 +- .../src/EventHandlerService/appsettings.json | 2 + .../src/Job.IdentityDeletion/appsettings.json | 13 +- ...240321084302_IdentityAddress80.Designer.cs | 59 ++ .../20240321084302_IdentityAddress80.cs | 50 + .../ChallengesDbContextModelSnapshot.cs | 4 +- ...240321143836_IdentityAddress80.Designer.cs | 59 ++ .../20240321143836_IdentityAddress80.cs | 50 + .../ApplicationDbContextModelSnapshot.cs | 4 +- .../Devices.Application/ApplicationOptions.cs | 8 +- .../Commands/CreateIdentity/Handler.cs | 2 +- .../Users/Commands/SeedTestUsers/Handler.cs | 9 +- ...240307164829_IdentityAddress80.Designer.cs | 874 +++++++++++++++++ .../20240307164829_IdentityAddress80.cs | 228 +++++ .../DevicesDbContextModelSnapshot.cs | 16 +- ...240307143640_IdentityAddress80.Designer.cs | 879 ++++++++++++++++++ .../20240307143640_IdentityAddress80.cs | 230 +++++ .../ApplicationDbContextModelSnapshot.cs | 16 +- .../Identities/ApproveDeletionProcessTests.cs | 2 +- .../DeletionGracePeriodReminderTests.cs | 2 +- .../DeletionProcessApprovalReminderTests.cs | 2 +- .../Identities/RejectDeletionProcessTests.cs | 2 +- .../StartDeletionProcessAsOwnerTests.cs | 2 +- .../StartDeletionProcessAsSupportTests.cs | 2 +- .../DirectPush/ApnsMessageBuilderTests.cs | 4 +- ...lePushNotificationServiceConnectorTests.cs | 2 +- .../DirectPush/FcmMessageBuilderTests.cs | 6 +- ...240321084224_IdentityAddress80.Designer.cs | 120 +++ .../20240321084224_IdentityAddress80.cs | 140 +++ .../Migrations/FilesDbContextModelSnapshot.cs | 16 +- ...240321143901_IdentityAddress80.Designer.cs | 120 +++ .../20240321143901_IdentityAddress80.cs | 140 +++ .../ApplicationDbContextModelSnapshot.cs | 16 +- .../ApplicationOptions.cs | 10 +- .../AnonymizeMessagesOfIdentity/Handler.cs | 2 +- ...240321084209_IdentityAddress80.Designer.cs | 208 +++++ .../20240321084209_IdentityAddress80.cs | 78 ++ .../MessagesDbContextModelSnapshot.cs | 16 +- ...240321144413_IdentityAddress80.Designer.cs | 208 +++++ .../20240321144413_IdentityAddress80.cs | 78 ++ .../ApplicationDbContextModelSnapshot.cs | 16 +- ...240307164716_IdentityAddress80.Designer.cs | 351 +++++++ .../20240307164716_IdentityAddress80.cs | 241 +++++ .../QuotasDbContextModelSnapshot.cs | 10 +- ...240307154323_IdentityAddress80.Designer.cs | 351 +++++++ .../20240307154323_IdentityAddress80.cs | 239 +++++ .../QuotasDbContextModelSnapshot.cs | 10 +- .../TestDoubles/UserContextStub.cs | 2 +- .../CreateQuotaForIdentity/HandlerTests.cs | 25 +- ...240506122429_IdentityAddress80.Designer.cs | 250 +++++ .../20240506122429_IdentityAddress80.cs | 168 ++++ .../RelationshipsDbContextModelSnapshot.cs | 22 +- ...240506122507_IdentityAddress80.Designer.cs | 250 +++++ .../20240506122507_IdentityAddress80.cs | 168 ++++ .../RelationshipsDbContextModelSnapshot.cs | 22 +- ...ionshipTemplateQueryableExtensionsTests.cs | 4 +- ...240321083947_IdentityAddress80.Designer.cs | 325 +++++++ .../20240321083947_IdentityAddress80.cs | 138 +++ .../SynchronizationDbContextModelSnapshot.cs | 16 +- ...240321144459_IdentityAddress80.Designer.cs | 325 +++++++ .../20240321144459_IdentityAddress80.cs | 138 +++ .../ApplicationDbContextModelSnapshot.cs | 16 +- .../TestDataGenerator.cs | 2 +- .../TestDataGenerator.cs | 2 +- ...240321084133_IdentityAddress80.Designer.cs | 69 ++ .../20240321084133_IdentityAddress80.cs | 48 + .../TokensDbContextModelSnapshot.cs | 4 +- ...240321144548_IdentityAddress80.Designer.cs | 69 ++ .../20240321144548_IdentityAddress80.cs | 48 + .../ApplicationDbContextModelSnapshot.cs | 4 +- .../adminui.appsettings.override.json | 1 - 79 files changed, 6954 insertions(+), 236 deletions(-) create mode 100644 Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.Designer.cs create mode 100644 Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.cs create mode 100644 Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.Designer.cs create mode 100644 Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.cs create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.Designer.cs create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.cs create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.Designer.cs create mode 100644 Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.cs create mode 100644 Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.Designer.cs create mode 100644 Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.cs create mode 100644 Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.Designer.cs create mode 100644 Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.cs create mode 100644 Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.Designer.cs create mode 100644 Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.cs create mode 100644 Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.Designer.cs create mode 100644 Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.cs create mode 100644 Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.Designer.cs create mode 100644 Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.cs create mode 100644 Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.Designer.cs create mode 100644 Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.cs create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.Designer.cs create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.cs create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.Designer.cs create mode 100644 Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.cs create mode 100644 Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.Designer.cs create mode 100644 Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.cs create mode 100644 Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.Designer.cs create mode 100644 Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.cs create mode 100644 Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.Designer.cs create mode 100644 Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.cs create mode 100644 Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.Designer.cs create mode 100644 Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.cs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eedeeed3f2..94bd02176c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -115,7 +115,7 @@ jobs: with: repository: nmshd/runtime path: runtime - ref: release/v5 + ref: feature/backbone-specific-addresses - name: Run Consumer API run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml up -d - name: Install runtime dependencies @@ -153,7 +153,7 @@ jobs: with: repository: nmshd/runtime path: runtime - ref: release/v5 + ref: feature/backbone-specific-addresses - name: Run Consumer API run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml up -d - name: Install runtime dependencies diff --git a/AdminApi/src/AdminApi/appsettings.json b/AdminApi/src/AdminApi/appsettings.json index f3ef3648ac..bdcd9b0017 100644 --- a/AdminApi/src/AdminApi/appsettings.json +++ b/AdminApi/src/AdminApi/appsettings.json @@ -22,7 +22,7 @@ }, "Devices": { "Application": { - "AddressPrefix": "id1", + "InstanceUrl": "prod.enmeshed.eu", "Pagination": { "DefaultPageSize": 50, "MaxPageSize": 200 diff --git a/AdminApi/src/AdminApi/appsettings.override.json b/AdminApi/src/AdminApi/appsettings.override.json index fac7faae2a..ce0079fd28 100644 --- a/AdminApi/src/AdminApi/appsettings.override.json +++ b/AdminApi/src/AdminApi/appsettings.override.json @@ -32,7 +32,6 @@ "Modules": { "Devices": { "Application": { - "AddressPrefix": "id1", "Pagination": { "DefaultPageSize": 50, "MaxPageSize": 200 diff --git a/Backbone.sln.DotSettings b/Backbone.sln.DotSettings index 2654474cc2..a31cc8851e 100644 --- a/Backbone.sln.DotSettings +++ b/Backbone.sln.DotSettings @@ -1,4 +1,4 @@ - + True SUGGESTION DO_NOT_SHOW @@ -32,6 +32,7 @@ True True True + True True True True diff --git a/BuildingBlocks/src/DevelopmentKit.Identity/ValueObjects/IdentityAddress.cs b/BuildingBlocks/src/DevelopmentKit.Identity/ValueObjects/IdentityAddress.cs index df3822d9d2..67328c6ada 100644 --- a/BuildingBlocks/src/DevelopmentKit.Identity/ValueObjects/IdentityAddress.cs +++ b/BuildingBlocks/src/DevelopmentKit.Identity/ValueObjects/IdentityAddress.cs @@ -2,17 +2,19 @@ using System.Globalization; using System.Security.Cryptography; using System.Text; +using System.Text.RegularExpressions; using Backbone.BuildingBlocks.Domain; using Backbone.BuildingBlocks.Domain.StronglyTypedIds.Records; -using SimpleBase; namespace Backbone.DevelopmentKit.Identity.ValueObjects; [Serializable] [TypeConverter(typeof(IdentityAddressTypeConverter))] -public record IdentityAddress : StronglyTypedId +public partial record IdentityAddress : StronglyTypedId { - public const int MAX_LENGTH = 36; + public const int MAX_LENGTH = 80; + private const int CHECKSUM_LENGTH = 2; + private const string CHECKSUM_LENGTH_S = "2"; private IdentityAddress(string stringValue) : base(stringValue) { @@ -43,39 +45,45 @@ public static bool IsValid(string? stringValue) { if (stringValue == null) return false; - var lengthIsValid = stringValue.Length <= MAX_LENGTH; + if (stringValue.Length > MAX_LENGTH) + return false; - var realm = stringValue[..3]; + var matches = IdentityAddressValidatorRegex().Matches(stringValue); - var concatenation = Base58.Bitcoin.Decode(stringValue.AsSpan(3)).ToArray(); - var hashedPublicKey = concatenation[..20]; - var givenChecksum = concatenation[20..]; + if (matches.Count == 0) return false; - var realmBytes = Encoding.UTF8.GetBytes(realm); - var correctChecksum = CalculateChecksum(realmBytes, hashedPublicKey); + var matchGroups = matches.First().Groups; - var checksumIsValid = givenChecksum.SequenceEqual(correctChecksum); + if (!matchGroups.TryGetValue("checksum", out var givenChecksum)) + return false; - return lengthIsValid && checksumIsValid; + if (!matchGroups.TryGetValue("addressWithoutChecksum", out var addressWithoutChecksum)) + return false; + + var expectedChecksum = CalculateChecksum(addressWithoutChecksum.Value); + + var checksumIsValid = givenChecksum.Value == expectedChecksum; + + return checksumIsValid; } - public static IdentityAddress Create(byte[] publicKey, string realm) + public static IdentityAddress Create(byte[] publicKey, string instanceUrl) { - var hashedPublicKey = SHA256.Create().ComputeHash(SHA512.Create().ComputeHash(publicKey))[..20]; - var realmBytes = Encoding.UTF8.GetBytes(realm); - var checksum = CalculateChecksum(realmBytes, hashedPublicKey); - var concatenation = hashedPublicKey.Concat(checksum).ToArray(); - var address = realm + Base58.Bitcoin.Encode(concatenation); + var hashedPublicKey = SHA256.HashData(SHA512.HashData(publicKey))[..10]; + + var identitySpecificPart = Hex(hashedPublicKey); - return new IdentityAddress(address); + var mainPhrase = $"did:e:{instanceUrl}:dids:{identitySpecificPart}"; + var checksum = CalculateChecksum(mainPhrase); + + return new IdentityAddress((mainPhrase + checksum).ToLower()); } - private static byte[] CalculateChecksum(byte[] realmBytes, byte[] hashedPublicKey) + private static string CalculateChecksum(string phrase) => Hex(SHA256.HashData(Encoding.ASCII.GetBytes(phrase)))[..CHECKSUM_LENGTH]; + + private static string Hex(byte[] bytes) { - var checksumSource = realmBytes.Concat(hashedPublicKey).ToArray(); - var checksumHash = SHA256.Create().ComputeHash(SHA512.Create().ComputeHash(checksumSource)); - var checksum = checksumHash[..4]; - return checksum; + return Convert.ToHexString(bytes).ToLower(); } public override string ToString() @@ -116,5 +124,8 @@ public static implicit operator IdentityAddress(string stringValue) return ParseUnsafe(stringValue); } + [GeneratedRegex($@"^(?did:e:(?(?:[a-z0-9]+\.)+[a-z]{{2,}}):dids:(?[0-9abcdef]{{20}}))(?[0-9abcdef]{{{CHECKSUM_LENGTH_S}}})$")] + private static partial Regex IdentityAddressValidatorRegex(); + #endregion } diff --git a/BuildingBlocks/src/UnitTestTools/Data/TestDataGenerator.cs b/BuildingBlocks/src/UnitTestTools/Data/TestDataGenerator.cs index 589f96dfd5..a59265ecfe 100644 --- a/BuildingBlocks/src/UnitTestTools/Data/TestDataGenerator.cs +++ b/BuildingBlocks/src/UnitTestTools/Data/TestDataGenerator.cs @@ -14,7 +14,7 @@ public static string GenerateString(int resultLength, char[]? chars = null) public static IdentityAddress CreateRandomIdentityAddress() { - return IdentityAddress.Create(CreateRandomBytes(), "id1"); + return IdentityAddress.Create(CreateRandomBytes(), "prod.enmeshed.eu"); } public static DeviceId CreateRandomDeviceId() diff --git a/BuildingBlocks/test/DevelopmentKit.Identity.Tests/IdentityAddressTests.cs b/BuildingBlocks/test/DevelopmentKit.Identity.Tests/IdentityAddressTests.cs index ffbe5c870a..1ccd4e5168 100644 --- a/BuildingBlocks/test/DevelopmentKit.Identity.Tests/IdentityAddressTests.cs +++ b/BuildingBlocks/test/DevelopmentKit.Identity.Tests/IdentityAddressTests.cs @@ -7,29 +7,46 @@ namespace Backbone.DevelopmentKit.Identity.Tests; public class IdentityAddressTests { [Theory] - [InlineData("fj0o9eOiPRswTZL6j9lE9TRvpDDnPRMF0gJeahz/W2c=", "id1QF24Gk2DfqCywRS7NpeH5iu7D4xvu6qv1")] - [InlineData("jRxGfZtQ8a90TmKCGk+dhuX1CBjgoXuldhNPwrjpWsw=", "id1HwY1TuyVBp3CmY3h18yTt1CKyu5qwB9wj")] - [InlineData("PEODpwvi7KxIVa4qeUXia9apMFvPMktdDHiDitlfbjE=", "id1LMp4k1XwxZ3WFXdAn9y12tv1ofe5so4kM")] - [InlineData("mJGmNbxiVZAPToRuk9O3NvdfsWl6V+7wzIc+/57bU08=", "id1McegXycvRoiJppS2LG25phn3jNveckFUL")] - [InlineData("l68K/zdNp1VLoswcHAqN6QUFwCMU6Yvzf7XiW2m1hRY=", "id193k6K5cJr94WJEWYb6Kei8zp5CGPyrQLS")] - [InlineData("Gl8XTo8qFuUM+ksXixwp4g/jf3H/hU1F8ETuYaHCM5I=", "id1BLrHAgDpimtLcGJGssMSm7bJHsvVe7CN")] - [InlineData("rIS4kAzHXT7GgCA6Qm1ANlwM3x12QMSkeprHb6tjPyc=", "id1NjGvLfWPrQ34PXWRBNiTfXv9DFiDQHExx")] - [InlineData("hg/cbeBvfNrMiJ0dW1AtWC4IQwG4gkuhzG2+z6bAoRU=", "id1Gda4aTXiBX9Pyc8UnmLaG44cX46umjnea")] - [InlineData("kId+qWen/lKeTdyxcIQhkzvvvTU8wIJECfWUWbmRQRY=", "id17RDEphijMPFGLbhqLWWgJfatBANMruC8f")] - [InlineData("NcqlzTEpSlKX9gmNBv41EjPRHpaNYwt0bxqh1bgyJzA=", "id19meHs4Di7JYNXoRPx9bFD6FUcpHFo3mBi")] - [InlineData("49fWA+kzWNdCFdo92imTiQ4vUUJsPPLNlcB9udC4ooE=", "id1c711BBi4yqV9wrLBVKxRSNFayfAm3Eib")] + // ReSharper disable StringLiteralTypo + [InlineData("49fWA+kzWNdCFdo92imTiQ4vUUJsPPLNlcB9udC4ooE=", "did:e:prod.enmeshed.eu:dids:06a391378e5df5c1399f77")] + [InlineData("fj0o9eOiPRswTZL6j9lE9TRvpDDnPRMF0gJeahz/W2c=", "did:e:prod.enmeshed.eu:dids:fef1992c5e529adc413288")] + [InlineData("Gl8XTo8qFuUM+ksXixwp4g/jf3H/hU1F8ETuYaHCM5I=", "did:e:prod.enmeshed.eu:dids:01f4bab09d757578bb4994")] + [InlineData("hg/cbeBvfNrMiJ0dW1AtWC4IQwG4gkuhzG2+z6bAoRU=", "did:e:prod.enmeshed.eu:dids:ab7475ba4070f29ce286fd")] + [InlineData("jRxGfZtQ8a90TmKCGk+dhuX1CBjgoXuldhNPwrjpWsw=", "did:e:prod.enmeshed.eu:dids:b9d25bd0a2bbd3aa48437c")] + [InlineData("kId+qWen/lKeTdyxcIQhkzvvvTU8wIJECfWUWbmRQRY=", "did:e:prod.enmeshed.eu:dids:4664f42d7ca6480db07fdb")] + [InlineData("l68K/zdNp1VLoswcHAqN6QUFwCMU6Yvzf7XiW2m1hRY=", "did:e:prod.enmeshed.eu:dids:5845cf29fbda2897892a9a")] + [InlineData("mJGmNbxiVZAPToRuk9O3NvdfsWl6V+7wzIc+/57bU08=", "did:e:prod.enmeshed.eu:dids:e2208784ee2769c5d9684d")] + [InlineData("NcqlzTEpSlKX9gmNBv41EjPRHpaNYwt0bxqh1bgyJzA=", "did:e:prod.enmeshed.eu:dids:60326ff5075e0d7378990c")] + [InlineData("PEODpwvi7KxIVa4qeUXia9apMFvPMktdDHiDitlfbjE=", "did:e:prod.enmeshed.eu:dids:d459ff2144f0eac7aff554")] + [InlineData("rIS4kAzHXT7GgCA6Qm1ANlwM3x12QMSkeprHb6tjPyc=", "did:e:prod.enmeshed.eu:dids:ee5966a158f1dc4de5bd5c")] + // ReSharper enable StringLiteralTypo public void AddressIsCreatedCorrectly2(string publicKey, string expectedAddress) { - var address = IdentityAddress.Create(Convert.FromBase64String(publicKey), "id1"); + var address = IdentityAddress.Create(Convert.FromBase64String(publicKey), "prod.enmeshed.eu"); address.Value.Should().Be(expectedAddress); } + [Theory] + // ReSharper disable StringLiteralTypo + [InlineData("did:e:enmeshedeu:dids:06a391378e5df5c1399f77")] + [InlineData("did:e:prod.ENMESHED.eu:dids:fef1992c5e529adc413288")] + [InlineData("ID154565465468435134684648ffef1992ca5e529adc413288")] + [InlineData("dod:e:prod.enmeshed.eu:dids:ee5966a158f1dc4de5bd5c")] + [InlineData("did:e:prod.enmeshed.eu:dids:nonhexchars11")] + [InlineData("did:e:prod.enmeshed.eu:dids:eCa432178Ca417a1311")] // capital letters + [InlineData("did:e:prod.enmeshed.eu:dids:ee5966a158f1dc4de5bd5cee5966a158f1dc4de5bd5c")] + // ReSharper enable StringLiteralTypo + public void IsValidReturnsFalseForInvalidAddress(string identityAddress) + { + IdentityAddress.IsValid(identityAddress).Should().BeFalse(); + } + [Fact] public void AddressIsCreatedCorrectly() { var testData = TestData.Valid(); - var address = IdentityAddress.Create(testData.PublicKey, testData.Realm); + var address = IdentityAddress.Create(testData.PublicKey, testData.InstanceUrl); address.Value.Should().Be(testData.Address); } @@ -38,7 +55,7 @@ public void AddressIsCreatedCorrectly() public void EfConverterWorksCorrectly() { var testData = TestData.Valid(); - var address = IdentityAddress.Create(testData.PublicKey, testData.Realm); + var address = IdentityAddress.Create(testData.PublicKey, testData.InstanceUrl); address.Value.Should().Be(testData.Address); } @@ -52,15 +69,6 @@ public void ValidAddressesAreAccepted() isValid.Should().BeTrue(); } - [Fact] - public void AddressesWithInvalidRealmAreDeclined() - { - var testData = TestData.WithInvalidRealm(); - var isValid = IdentityAddress.IsValid(testData.Address); - - isValid.Should().BeFalse(); - } - [Fact] public void AddressesWithInvalidChecksumAreDeclined() { @@ -82,35 +90,21 @@ public void AddressesWithInvalidMainPartAreDeclined() internal class TestData { - public required string Realm { get; set; } + public required string InstanceUrl { get; set; } public required byte[] PublicKey { get; set; } public required string Address { get; set; } public required string Checksum { get; set; } - public required string MainPart { get; set; } public static TestData Valid() { return new TestData { - Address = "id18uSgVGTSNqECvt1DJM3bZg6U8p6RSjott", - PublicKey = Convert.FromBase64String("tB9KFp/YqHrom3m5qUuZsd6l30DkaNjN14SxRw7YZuI="), - Realm = "id1", - Checksum = "jott", - MainPart = "8uSgVGTSNqECvt1DJM3bZg6U8p6RS" - }; - } - - public static TestData WithInvalidRealm() - { - return new TestData - { - Address = "id08uSgVGTSNqECvt1DJM3bZg6U8p6RSjott", + Address = "did:e:prod.enmeshed.eu:dids:56b3f2a0c202e27229aa87", PublicKey = Convert.FromBase64String("tB9KFp/YqHrom3m5qUuZsd6l30DkaNjN14SxRw7YZuI="), - Realm = "id0", - Checksum = "jott", - MainPart = "8uSgVGTSNqECvt1DJM3bZg6U8p6RS" + Checksum = "87", + InstanceUrl = "prod.enmeshed.eu" }; } @@ -118,11 +112,10 @@ public static TestData WithInvalidMainPart() { return new TestData { - Address = "id07uSgVGTSNqECvt1DJM3bZg6U8p6RSjott", + Address = "did:e:prod.enmeshed.eu:dids:56b3f2a0c202e27d39aa87", PublicKey = Convert.FromBase64String("tB9KFp/YqHrom3m5qUuZsd6l30DkaNjN14SxRw7YZuI="), - Realm = "id0", - Checksum = "jott", - MainPart = "7uSgVGTSNqECvt1DJM3bZg6U8p6RS" + Checksum = "87", + InstanceUrl = "prod.enmeshed.eu" }; } @@ -130,11 +123,10 @@ public static TestData WithInvalidChecksum() { return new TestData { - Address = "id08uSgVGTSNqECvt1DJM3bZg6U8p6RSiott", + Address = "did:e:prod.enmeshed.eu:dids:56b3f2a0c202e27229aa55", PublicKey = Convert.FromBase64String("tB9KFp/YqHrom3m5qUuZsd6l30DkaNjN14SxRw7YZuI="), - Realm = "id0", - Checksum = "iott", - MainPart = "8uSgVGTSNqECvt1DJM3bZg6U8p6RS" + Checksum = "55", + InstanceUrl = "prod.enmeshed.eu" }; } } diff --git a/ConsumerApi.Tests.Integration/appsettings.json b/ConsumerApi.Tests.Integration/appsettings.json index 18bd1d20a8..6d255f9aef 100644 --- a/ConsumerApi.Tests.Integration/appsettings.json +++ b/ConsumerApi.Tests.Integration/appsettings.json @@ -5,5 +5,17 @@ "ClientId": "test", "ClientSecret": "test" } + }, + "Modules": { + "Devices": { + "Application": { + "InstanceUrl": "pipeline.test.enmeshed.eu" + } + }, + "Messages": { + "Application": { + "InstanceUrl": "pipeline.test.enmeshed.eu" + } + } } } diff --git a/ConsumerApi/appsettings.json b/ConsumerApi/appsettings.json index 7bc9262056..d42ea5c3f3 100644 --- a/ConsumerApi/appsettings.json +++ b/ConsumerApi/appsettings.json @@ -28,7 +28,7 @@ }, "Devices": { "Application": { - "AddressPrefix": "id1", + "InstanceUrl": "prod.enmeshed.eu", "Pagination": { "DefaultPageSize": 50, "MaxPageSize": 200 @@ -45,7 +45,7 @@ }, "Messages": { "Application": { - "AddressPrefix": "id1", + "InstanceUrl": "prod.enmeshed.eu", "MaxNumberOfUnreceivedMessagesFromOneSender": 20, "Pagination": { "DefaultPageSize": 50, diff --git a/EventHandlerService/src/EventHandlerService/appsettings.json b/EventHandlerService/src/EventHandlerService/appsettings.json index 2bbd40d624..0315d8dd6e 100644 --- a/EventHandlerService/src/EventHandlerService/appsettings.json +++ b/EventHandlerService/src/EventHandlerService/appsettings.json @@ -22,6 +22,7 @@ "Devices": { "Application": { "AddressPrefix": "id1", + "InstanceUrl": "pipeline.test.enmeshed.eu", "Pagination": { "DefaultPageSize": 50, "MaxPageSize": 200 @@ -39,6 +40,7 @@ "Messages": { "Application": { "AddressPrefix": "id1", + "InstanceUrl": "pipeline.test.enmeshed.eu", "MaxNumberOfUnreceivedMessagesFromOneSender": 20, "Pagination": { "DefaultPageSize": 50, diff --git a/Jobs/src/Job.IdentityDeletion/appsettings.json b/Jobs/src/Job.IdentityDeletion/appsettings.json index 2bbd40d624..005d1d3405 100644 --- a/Jobs/src/Job.IdentityDeletion/appsettings.json +++ b/Jobs/src/Job.IdentityDeletion/appsettings.json @@ -21,7 +21,6 @@ }, "Devices": { "Application": { - "AddressPrefix": "id1", "Pagination": { "DefaultPageSize": 50, "MaxPageSize": 200 @@ -38,12 +37,12 @@ }, "Messages": { "Application": { - "AddressPrefix": "id1", - "MaxNumberOfUnreceivedMessagesFromOneSender": 20, - "Pagination": { - "DefaultPageSize": 50, - "MaxPageSize": 200 - } + "InstanceUrl": "prod.enmeshed.eu", + "MaxNumberOfUnreceivedMessagesFromOneSender": 20, + "Pagination": { + "DefaultPageSize": 50, + "MaxPageSize": 200 + } } }, "Relationships": { diff --git a/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.Designer.cs b/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..75e72e2f2f --- /dev/null +++ b/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.Designer.cs @@ -0,0 +1,59 @@ +// +using System; +using Backbone.Modules.Challenges.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Challenges.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(ChallengesDbContext))] + [Migration("20240321084302_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Challenges") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Challenges.Domain.Entities.Challenge", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedBy") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Challenges"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.cs b/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.cs new file mode 100644 index 0000000000..e37a60b95e --- /dev/null +++ b/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/20240321084302_IdentityAddress80.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Challenges.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Challenges", + table: "Challenges", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: true, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36, + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Challenges", + table: "Challenges", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: true, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80, + oldNullable: true); + } + } +} diff --git a/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/ChallengesDbContextModelSnapshot.cs b/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/ChallengesDbContextModelSnapshot.cs index b7f0f515dd..b285434360 100644 --- a/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/ChallengesDbContextModelSnapshot.cs +++ b/Modules/Challenges/src/Challenges.Infrastructure.Database.Postgres/Migrations/ChallengesDbContextModelSnapshot.cs @@ -32,9 +32,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsFixedLength(); b.Property("CreatedBy") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.Designer.cs b/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..2a2d7614f4 --- /dev/null +++ b/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.Designer.cs @@ -0,0 +1,59 @@ +// +using System; +using Backbone.Modules.Challenges.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Challenges.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(ChallengesDbContext))] + [Migration("20240321143836_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Challenges") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Challenges.Domain.Entities.Challenge", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedBy") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Challenges"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.cs b/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.cs new file mode 100644 index 0000000000..9f65974d53 --- /dev/null +++ b/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/20240321143836_IdentityAddress80.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Challenges.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Challenges", + table: "Challenges", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: true, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36, + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Challenges", + table: "Challenges", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: true, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80, + oldNullable: true); + } + } +} diff --git a/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs b/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs index f378414eb5..10cdc2dbb9 100644 --- a/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Modules/Challenges/src/Challenges.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs @@ -32,9 +32,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsFixedLength(); b.Property("CreatedBy") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/Modules/Devices/src/Devices.Application/ApplicationOptions.cs b/Modules/Devices/src/Devices.Application/ApplicationOptions.cs index 14f2e6b1c9..08cfd816a7 100644 --- a/Modules/Devices/src/Devices.Application/ApplicationOptions.cs +++ b/Modules/Devices/src/Devices.Application/ApplicationOptions.cs @@ -5,12 +5,12 @@ namespace Backbone.Modules.Devices.Application; public class ApplicationOptions { [Required] - [MinLength(3)] - [MaxLength(3)] - public string AddressPrefix { get; set; } = null!; + public PaginationOptions Pagination { get; set; } = new(); [Required] - public PaginationOptions Pagination { get; set; } = new(); + [MinLength(3)] + [MaxLength(45)] + public string InstanceUrl { get; set; } = null!; } public class PaginationOptions diff --git a/Modules/Devices/src/Devices.Application/Identities/Commands/CreateIdentity/Handler.cs b/Modules/Devices/src/Devices.Application/Identities/Commands/CreateIdentity/Handler.cs index 10bb0002b1..cc9e3a0966 100644 --- a/Modules/Devices/src/Devices.Application/Identities/Commands/CreateIdentity/Handler.cs +++ b/Modules/Devices/src/Devices.Application/Identities/Commands/CreateIdentity/Handler.cs @@ -40,7 +40,7 @@ public async Task Handle(CreateIdentityCommand command, _logger.LogTrace("Challenge successfully validated."); - var address = IdentityAddress.Create(publicKey.Key, _applicationOptions.AddressPrefix); + var address = IdentityAddress.Create(publicKey.Key, _applicationOptions.InstanceUrl); _logger.LogTrace("Address created. Result: '{address}'", address); diff --git a/Modules/Devices/src/Devices.Application/Users/Commands/SeedTestUsers/Handler.cs b/Modules/Devices/src/Devices.Application/Users/Commands/SeedTestUsers/Handler.cs index e63dceba27..3b88f21ab8 100644 --- a/Modules/Devices/src/Devices.Application/Users/Commands/SeedTestUsers/Handler.cs +++ b/Modules/Devices/src/Devices.Application/Users/Commands/SeedTestUsers/Handler.cs @@ -5,20 +5,23 @@ using Backbone.Tooling; using MediatR; using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Options; namespace Backbone.Modules.Devices.Application.Users.Commands.SeedTestUsers; public class Handler : IRequestHandler { private readonly IPasswordHasher _passwordHasher; + private readonly ApplicationOptions _applicationOptions; private readonly IDevicesDbContext _dbContext; private readonly ITiersRepository _tiersRepository; - public Handler(IDevicesDbContext context, ITiersRepository tiersRepository, IPasswordHasher passwordHasher) + public Handler(IDevicesDbContext context, ITiersRepository tiersRepository, IPasswordHasher passwordHasher, IOptions applicationOptions) { _dbContext = context; _tiersRepository = tiersRepository; _passwordHasher = passwordHasher; + _applicationOptions = applicationOptions.Value; } public async Task Handle(SeedTestUsersCommand request, CancellationToken cancellationToken) @@ -26,7 +29,7 @@ public async Task Handle(SeedTestUsersCommand request, CancellationToken cancell var basicTier = await _tiersRepository.FindBasicTier(cancellationToken); var user = new ApplicationUser(new Device(new Identity("test", - IdentityAddress.Create([1, 1, 1, 1, 1], "id1"), + IdentityAddress.Create([1, 1, 1, 1, 1], _applicationOptions.InstanceUrl), [1, 1, 1, 1, 1], basicTier!.Id, 1 ))) { @@ -39,7 +42,7 @@ public async Task Handle(SeedTestUsersCommand request, CancellationToken cancell await _dbContext.Set().AddAsync(user, cancellationToken); user = new ApplicationUser(new Device(new Identity("test", - IdentityAddress.Create([2, 2, 2, 2, 2], "id1"), + IdentityAddress.Create([2, 2, 2, 2, 2], _applicationOptions.InstanceUrl), [2, 2, 2, 2, 2], basicTier.Id, 1 ))) { diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.Designer.cs b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..877ca78e55 --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.Designer.cs @@ -0,0 +1,874 @@ +// +using System; +using Backbone.Modules.Devices.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(DevicesDbContext))] + [Migration("20240307164829_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Devices") + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.PushNotifications.PnsRegistration", b => + { + b.Property("DeviceId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("AppId") + .IsRequired() + .HasColumnType("text"); + + b.Property("DevicePushIdentifier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Environment") + .HasColumnType("integer"); + + b.Property("Handle") + .IsRequired() + .HasMaxLength(200) + .IsUnicode(true) + .HasColumnType("character varying(200)") + .IsFixedLength(false); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("DeviceId"); + + b.ToTable("PnsRegistrations"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .IsUnicode(true) + .HasColumnType("character varying(30)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Tiers"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Challenge", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("Challenges", "Challenges", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("LastLoginAt") + .HasColumnType("timestamp with time zone"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("UserName") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Property("Address") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("ClientId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletionGracePeriodEndsAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IdentityVersion") + .HasColumnType("smallint"); + + b.Property("PublicKey") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TierId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("TierIdBeforeDeletion") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Address"); + + b.ToTable("Identities"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ApprovalReminder1SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovalReminder2SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovalReminder3SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ApprovedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CancelledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CancelledByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodEndsAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodReminder1SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodReminder2SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("GracePeriodReminder3SentAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IdentityAddress") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("IdentityDeletionProcesses", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeviceIdHash") + .HasColumnType("bytea"); + + b.Property("IdentityAddressHash") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("IdentityDeletionProcessId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("NewStatus") + .HasColumnType("integer"); + + b.Property("OldStatus") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("IdentityDeletionProcessId"); + + b.ToTable("IdentityDeletionProcessAuditLog", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ApplicationType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ClientId") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("ClientSecret") + .HasColumnType("text"); + + b.Property("ClientType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ConsentType") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DefaultTier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("DisplayNames") + .HasColumnType("text"); + + b.Property("JsonWebKeySet") + .HasColumnType("text"); + + b.Property("MaxIdentities") + .HasColumnType("integer"); + + b.Property("Permissions") + .HasColumnType("text"); + + b.Property("PostLogoutRedirectUris") + .HasColumnType("text"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("RedirectUris") + .HasColumnType("text"); + + b.Property("Requirements") + .HasColumnType("text"); + + b.Property("Settings") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ClientId") + .IsUnique(); + + b.HasIndex("DefaultTier"); + + b.ToTable("OpenIddictApplications", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ApplicationId") + .HasColumnType("text"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("Scopes") + .HasColumnType("text"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("character varying(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictAuthorizations", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Descriptions") + .HasColumnType("text"); + + b.Property("DisplayName") + .HasColumnType("text"); + + b.Property("DisplayNames") + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("Resources") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("OpenIddictScopes", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("ApplicationId") + .HasColumnType("text"); + + b.Property("AuthorizationId") + .HasColumnType("text"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpirationDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Payload") + .HasColumnType("text"); + + b.Property("Properties") + .HasColumnType("text"); + + b.Property("RedemptionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ReferenceId") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("character varying(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizationId"); + + b.HasIndex("ReferenceId") + .IsUnique(); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Device", "Device") + .WithOne("User") + .HasForeignKey("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", "DeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", "Identity") + .WithMany("Devices") + .HasForeignKey("IdentityAddress") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Identity"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", null) + .WithMany("DeletionProcesses") + .HasForeignKey("IdentityAddress"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", null) + .WithMany("AuditLog") + .HasForeignKey("IdentityDeletionProcessId"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", null) + .WithMany() + .HasForeignKey("DefaultTier") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Authorizations") + .HasForeignKey("ApplicationId"); + + b.Navigation("Application"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Tokens") + .HasForeignKey("ApplicationId"); + + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", "Authorization") + .WithMany("Tokens") + .HasForeignKey("AuthorizationId"); + + b.Navigation("Application"); + + b.Navigation("Authorization"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Navigation("User") + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Navigation("DeletionProcesses"); + + b.Navigation("Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Navigation("AuditLog"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Navigation("Authorizations"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Navigation("Tokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.cs b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.cs new file mode 100644 index 0000000000..f55d86cfbc --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/20240307164829_IdentityAddress80.cs @@ -0,0 +1,228 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses"); + + migrationBuilder.DropForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities"); + + #region AlterColumns + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "PnsRegistrations", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: true, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Address", + schema: "Devices", + table: "Identities", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "Devices", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities", + column: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses"); + + migrationBuilder.DropForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities"); + + #region AlterColumns + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "PnsRegistrations", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: true, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Address", + schema: "Devices", + table: "Identities", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "Devices", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities", + column: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs index 4d77fac0b2..a294be289e 100644 --- a/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs +++ b/Modules/Devices/src/Devices.Infrastructure.Database.Postgres/Migrations/DevicesDbContextModelSnapshot.cs @@ -54,9 +54,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IdentityAddress") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("UpdatedAt") @@ -207,9 +207,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IdentityAddress") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.HasKey("Id"); @@ -222,9 +222,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => { b.Property("Address") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("ClientId") @@ -323,9 +323,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("timestamp with time zone"); b.Property("IdentityAddress") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("RejectedAt") diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.Designer.cs b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..b70988f630 --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.Designer.cs @@ -0,0 +1,879 @@ +// +using System; +using Backbone.Modules.Devices.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(DevicesDbContext))] + [Migration("20240307143640_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Devices") + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.PushNotifications.PnsRegistration", b => + { + b.Property("DeviceId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("AppId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DevicePushIdentifier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Environment") + .HasColumnType("int"); + + b.Property("Handle") + .IsRequired() + .HasMaxLength(200) + .IsUnicode(true) + .HasColumnType("nvarchar(200)") + .IsFixedLength(false); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("DeviceId"); + + b.ToTable("PnsRegistrations"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .IsUnicode(true) + .HasColumnType("nvarchar(30)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Tiers"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Challenge", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Challenges", "Challenges", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DeviceId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("LastLoginAt") + .HasColumnType("datetime2"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("DeletedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("IdentityAddress") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Property("Address") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("ClientId") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DeletionGracePeriodEndsAt") + .HasColumnType("datetime2"); + + b.Property("IdentityVersion") + .HasColumnType("tinyint"); + + b.Property("PublicKey") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("TierId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("TierIdBeforeDeletion") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Address"); + + b.ToTable("Identities"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ApprovalReminder1SentAt") + .HasColumnType("datetime2"); + + b.Property("ApprovalReminder2SentAt") + .HasColumnType("datetime2"); + + b.Property("ApprovalReminder3SentAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedAt") + .HasColumnType("datetime2"); + + b.Property("ApprovedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CancelledAt") + .HasColumnType("datetime2"); + + b.Property("CancelledByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodEndsAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodReminder1SentAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodReminder2SentAt") + .HasColumnType("datetime2"); + + b.Property("GracePeriodReminder3SentAt") + .HasColumnType("datetime2"); + + b.Property("IdentityAddress") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IdentityAddress"); + + b.ToTable("IdentityDeletionProcesses", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DeviceIdHash") + .HasColumnType("varbinary(max)"); + + b.Property("IdentityAddressHash") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("IdentityDeletionProcessId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Message") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("IdentityDeletionProcessId"); + + b.ToTable("IdentityDeletionProcessAuditLog", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ApplicationType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ClientId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("ClientSecret") + .HasColumnType("nvarchar(max)"); + + b.Property("ClientType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ConsentType") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("DefaultTier") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayNames") + .HasColumnType("nvarchar(max)"); + + b.Property("JsonWebKeySet") + .HasColumnType("nvarchar(max)"); + + b.Property("MaxIdentities") + .HasColumnType("int"); + + b.Property("Permissions") + .HasColumnType("nvarchar(max)"); + + b.Property("PostLogoutRedirectUris") + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("RedirectUris") + .HasColumnType("nvarchar(max)"); + + b.Property("Requirements") + .HasColumnType("nvarchar(max)"); + + b.Property("Settings") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClientId") + .IsUnique() + .HasFilter("[ClientId] IS NOT NULL"); + + b.HasIndex("DefaultTier"); + + b.ToTable("OpenIddictApplications", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ApplicationId") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("Scopes") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictAuthorizations", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreScope", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Descriptions") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayNames") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("Resources") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique() + .HasFilter("[Name] IS NOT NULL"); + + b.ToTable("OpenIddictScopes", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ApplicationId") + .HasColumnType("nvarchar(450)"); + + b.Property("AuthorizationId") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyToken") + .IsConcurrencyToken() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreationDate") + .HasColumnType("datetime2"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("Payload") + .HasColumnType("nvarchar(max)"); + + b.Property("Properties") + .HasColumnType("nvarchar(max)"); + + b.Property("RedemptionDate") + .HasColumnType("datetime2"); + + b.Property("ReferenceId") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Subject") + .HasMaxLength(400) + .HasColumnType("nvarchar(400)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizationId"); + + b.HasIndex("ReferenceId") + .IsUnique() + .HasFilter("[ReferenceId] IS NOT NULL"); + + b.HasIndex("ApplicationId", "Status", "Subject", "Type"); + + b.ToTable("OpenIddictTokens", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Device", "Device") + .WithOne("User") + .HasForeignKey("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", "DeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", "Identity") + .WithMany("Devices") + .HasForeignKey("IdentityAddress") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Identity"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", null) + .WithMany("DeletionProcesses") + .HasForeignKey("IdentityAddress"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcessAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", null) + .WithMany("AuditLog") + .HasForeignKey("IdentityDeletionProcessId"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Aggregates.Tier.Tier", null) + .WithMany() + .HasForeignKey("DefaultTier") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Authorizations") + .HasForeignKey("ApplicationId"); + + b.Navigation("Application"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreToken", b => + { + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", "Application") + .WithMany("Tokens") + .HasForeignKey("ApplicationId"); + + b.HasOne("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", "Authorization") + .WithMany("Tokens") + .HasForeignKey("AuthorizationId"); + + b.Navigation("Application"); + + b.Navigation("Authorization"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Backbone.Modules.Devices.Domain.Entities.Identities.ApplicationUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Device", b => + { + b.Navigation("User") + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => + { + b.Navigation("DeletionProcesses"); + + b.Navigation("Devices"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.IdentityDeletionProcess", b => + { + b.Navigation("AuditLog"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreApplication", b => + { + b.Navigation("Authorizations"); + + b.Navigation("Tokens"); + }); + + modelBuilder.Entity("Backbone.Modules.Devices.Infrastructure.OpenIddict.CustomOpenIddictEntityFrameworkCoreAuthorization", b => + { + b.Navigation("Tokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.cs b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.cs new file mode 100644 index 0000000000..3332f31128 --- /dev/null +++ b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/20240307143640_IdentityAddress80.cs @@ -0,0 +1,230 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Devices.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses"); + + migrationBuilder.DropForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities"); + + #region AlterColumns + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "PnsRegistrations", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: true, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Address", + schema: "Devices", + table: "Identities", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "Devices", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities", + column: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + migrationBuilder.DropForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses"); + + migrationBuilder.DropForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities"); + + #region AlterColumns + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "PnsRegistrations", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: true, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Address", + schema: "Devices", + table: "Identities", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "IdentityAddress", + schema: "Devices", + table: "Devices", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + name: "PK_Identities", + schema: "Devices", + table: "Identities", + column: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress", + schema: "Devices", + table: "IdentityDeletionProcesses", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_Devices_Identities_IdentityAddress", + schema: "Devices", + table: "Devices", + column: "IdentityAddress", + principalTable: "Identities", + principalSchema: "Devices", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs index e0cbaa08ec..d55b18f4b5 100644 --- a/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Modules/Devices/src/Devices.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs @@ -54,9 +54,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IdentityAddress") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("UpdatedAt") @@ -208,9 +208,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IdentityAddress") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.HasKey("Id"); @@ -223,9 +223,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Backbone.Modules.Devices.Domain.Entities.Identities.Identity", b => { b.Property("Address") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("ClientId") @@ -324,9 +324,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime2"); b.Property("IdentityAddress") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("RejectedAt") diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/ApproveDeletionProcessTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/ApproveDeletionProcessTests.cs index fc026aeb22..f6bbcdb5a2 100644 --- a/Modules/Devices/test/Devices.Domain.Tests/Identities/ApproveDeletionProcessTests.cs +++ b/Modules/Devices/test/Devices.Domain.Tests/Identities/ApproveDeletionProcessTests.cs @@ -96,7 +96,7 @@ private static void AssertAuditLogEntryWasCreated(IdentityDeletionProcess deleti private static Identity CreateIdentity() { - var address = IdentityAddress.Create([], "id1"); + var address = IdentityAddress.Create([], "prod.enmeshed.eu"); return new Identity("", address, [], TierId.Generate(), 1); } diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionGracePeriodReminderTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionGracePeriodReminderTests.cs index dac194a762..b600b76f32 100644 --- a/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionGracePeriodReminderTests.cs +++ b/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionGracePeriodReminderTests.cs @@ -137,7 +137,7 @@ private static Identity CreateIdentityWithApprovedDeletionProcess() private static Identity CreateIdentity() { - var address = IdentityAddress.Create(Array.Empty(), "id1"); + var address = IdentityAddress.Create(Array.Empty(), "prod.enmeshed.eu"); return new Identity("", address, Array.Empty(), TierId.Generate(), 1); } } diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionProcessApprovalReminderTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionProcessApprovalReminderTests.cs index 2743767af1..a112385d3d 100644 --- a/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionProcessApprovalReminderTests.cs +++ b/Modules/Devices/test/Devices.Domain.Tests/Identities/DeletionProcessApprovalReminderTests.cs @@ -146,7 +146,7 @@ private static Identity CreateIdentityWithDeletionProcessWaitingForApproval() private static Identity CreateIdentity() { - var address = IdentityAddress.Create(Array.Empty(), "id1"); + var address = IdentityAddress.Create(Array.Empty(), "prod.enmeshed.eu"); return new Identity("", address, Array.Empty(), TierId.Generate(), 1); } diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/RejectDeletionProcessTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/RejectDeletionProcessTests.cs index b29f2d1dd7..435bd00daf 100644 --- a/Modules/Devices/test/Devices.Domain.Tests/Identities/RejectDeletionProcessTests.cs +++ b/Modules/Devices/test/Devices.Domain.Tests/Identities/RejectDeletionProcessTests.cs @@ -96,7 +96,7 @@ private static void AssertAuditLogEntryWasCreated(IdentityDeletionProcess deleti private static Identity CreateIdentity() { - var address = IdentityAddress.Create([], "id1"); + var address = IdentityAddress.Create([], "prod.enmeshed.eu"); return new Identity("", address, [], TierId.Generate(), 1); } diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsOwnerTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsOwnerTests.cs index 524c05b1ad..48a2a17bb8 100644 --- a/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsOwnerTests.cs +++ b/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsOwnerTests.cs @@ -109,7 +109,7 @@ private static void AssertAuditLogEntryWasCreated(IdentityDeletionProcess deleti private static Identity CreateIdentity() { - var address = IdentityAddress.Create(Array.Empty(), "id1"); + var address = IdentityAddress.Create(Array.Empty(), "prod.enmeshed.eu"); return new Identity("", address, Array.Empty(), TierId.Generate(), 1); } } diff --git a/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsSupportTests.cs b/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsSupportTests.cs index 85c4cc6899..9dbdbda5fe 100644 --- a/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsSupportTests.cs +++ b/Modules/Devices/test/Devices.Domain.Tests/Identities/StartDeletionProcessAsSupportTests.cs @@ -74,7 +74,7 @@ private static void AssertAuditLogEntryWasCreated(IdentityDeletionProcess deleti private static Identity CreateIdentity() { - var address = IdentityAddress.Create(Array.Empty(), "id1"); + var address = IdentityAddress.Create(Array.Empty(), "prod.enmeshed.eu"); return new Identity("", address, Array.Empty(), TierId.Generate(), 1); } } diff --git a/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApnsMessageBuilderTests.cs b/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApnsMessageBuilderTests.cs index 48b3ab9b16..62abecdff3 100644 --- a/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApnsMessageBuilderTests.cs +++ b/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApnsMessageBuilderTests.cs @@ -33,7 +33,7 @@ public async Task Content_is_valid_json() // Act var request = new ApnsMessageBuilder("someAppBundleIdentifier", "https://api.development.push.apple.com/3/device/someDeviceId", "someValidJwt") - .AddContent(new NotificationContent(IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"), DevicePushIdentifier.Parse("DPIaaaaaaaaaaaaaaaaa"), new { SomeProperty = "someValue" })) + .AddContent(new NotificationContent(IdentityAddress.Parse("did:e:prod.enmeshed.eu:dids:b9d25bd0a2bbd3aa48437c"), DevicePushIdentifier.Parse("DPIaaaaaaaaaaaaaaaaa"), new { SomeProperty = "someValue" })) .SetNotificationText("someNotificationTextTitle", "someNotificationTextBody") .SetNotificationId(1) .Build(); @@ -43,7 +43,7 @@ public async Task Content_is_valid_json() requestBody.Should().Be(FormatJson(@"{ 'notId': 1, 'content': { - 'accRef': 'id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j', + 'accRef': 'did:e:prod.enmeshed.eu:dids:b9d25bd0a2bbd3aa48437c', 'devicePushIdentifier' : 'DPIaaaaaaaaaaaaaaaaa', 'eventName': 'dynamic', 'sentAt': '2021-01-01T00:00:00.000Z', diff --git a/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApplePushNotificationServiceConnectorTests.cs b/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApplePushNotificationServiceConnectorTests.cs index 1ee2d68a48..6b99d6e555 100644 --- a/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApplePushNotificationServiceConnectorTests.cs +++ b/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/ApplePushNotificationServiceConnectorTests.cs @@ -24,7 +24,7 @@ public async Task Notification_is_sent_successfully() var connector = CreateConnector(client); // Act - var recipient = IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"); + var recipient = IdentityAddress.Parse("did:e:prod.enmeshed.eu:dids:b9d25bd0a2bbd3aa48437c"); var registrations = new List { new(recipient, DeviceId.New(), PnsHandle.Parse(PushNotificationPlatform.Apns, "some-device-id").Value, APP_ID, PushEnvironment.Development) diff --git a/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/FcmMessageBuilderTests.cs b/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/FcmMessageBuilderTests.cs index d955836d70..cd8a5750ab 100644 --- a/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/FcmMessageBuilderTests.cs +++ b/Modules/Devices/test/Devices.Infrastructure.Tests/Tests/DirectPush/FcmMessageBuilderTests.cs @@ -19,7 +19,7 @@ public void Built_message_has_all_properties_set() .SetTag(1) .SetToken("token1") .SetNotificationText("someNotificationTextTitle", "someNotificationTextBody") - .AddContent(new NotificationContent(IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"), DevicePushIdentifier.New(), new { SomeProperty = "someValue" })) + .AddContent(new NotificationContent(IdentityAddress.Parse("did:e:prod.enmeshed.eu:dids:b9d25bd0a2bbd3aa48437c"), DevicePushIdentifier.New(), new { SomeProperty = "someValue" })) .Build(); // Assert @@ -45,13 +45,13 @@ public void Content_is_valid_json() // Act var message = new FcmMessageBuilder() - .AddContent(new NotificationContent(IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"), DevicePushIdentifier.Parse("DPIaaaaaaaaaaaaaaaaa"), new { SomeProperty = "someValue" })) + .AddContent(new NotificationContent(IdentityAddress.Parse("did:e:prod.enmeshed.eu:dids:b9d25bd0a2bbd3aa48437c"), DevicePushIdentifier.Parse("DPIaaaaaaaaaaaaaaaaa"), new { SomeProperty = "someValue" })) .Build(); var contentJson = FormatJson(message.Data["content"]); // Assert contentJson.Should().Be(FormatJson(@"{ - 'accRef': 'id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j', + 'accRef': 'did:e:prod.enmeshed.eu:dids:b9d25bd0a2bbd3aa48437c', 'devicePushIdentifier' : 'DPIaaaaaaaaaaaaaaaaa', 'eventName': 'dynamic', 'sentAt': '2021-01-01T00:00:00.000Z', diff --git a/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.Designer.cs b/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..214640b252 --- /dev/null +++ b/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.Designer.cs @@ -0,0 +1,120 @@ +// +using System; +using Backbone.Modules.Files.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Files.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(FilesDbContext))] + [Migration("20240321084224_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Files") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Files.Domain.Entities.File", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CipherHash") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("CipherSize") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("DeletedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("EncryptedProperties") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ModifiedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ModifiedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("ModifiedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("OwnerSignature") + .IsRequired() + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.ToTable("FileMetadata", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.cs b/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.cs new file mode 100644 index 0000000000..340a8d1ec9 --- /dev/null +++ b/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/20240321084224_IdentityAddress80.cs @@ -0,0 +1,140 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Files.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Files", + table: "FileMetadata", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "Files", + table: "FileMetadata", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + schema: "Files", + table: "FileMetadata", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: true, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Files", + table: "FileMetadata", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Files", + table: "FileMetadata", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "Files", + table: "FileMetadata", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + schema: "Files", + table: "FileMetadata", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: true, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Files", + table: "FileMetadata", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/FilesDbContextModelSnapshot.cs b/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/FilesDbContextModelSnapshot.cs index cc62f1b189..fd50f6fd55 100644 --- a/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/FilesDbContextModelSnapshot.cs +++ b/Modules/Files/src/Files.Infrastructure.Database.Postgres/Migrations/FilesDbContextModelSnapshot.cs @@ -43,9 +43,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -59,9 +59,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("timestamp with time zone"); b.Property("DeletedBy") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("DeletedByDevice") @@ -82,9 +82,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ModifiedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("ModifiedByDevice") @@ -96,9 +96,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Owner") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("OwnerSignature") diff --git a/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.Designer.cs b/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..1c795b04df --- /dev/null +++ b/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.Designer.cs @@ -0,0 +1,120 @@ +// +using System; +using Backbone.Modules.Files.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Files.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(FilesDbContext))] + [Migration("20240321143901_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Files") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Files.Domain.Entities.File", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CipherHash") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("CipherSize") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("DeletedBy") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("DeletedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("EncryptedProperties") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("ModifiedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("OwnerSignature") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.ToTable("FileMetadata", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.cs b/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.cs new file mode 100644 index 0000000000..6fb9a03d86 --- /dev/null +++ b/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/20240321143901_IdentityAddress80.cs @@ -0,0 +1,140 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Files.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Files", + table: "FileMetadata", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "Files", + table: "FileMetadata", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + schema: "Files", + table: "FileMetadata", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: true, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Files", + table: "FileMetadata", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Files", + table: "FileMetadata", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + schema: "Files", + table: "FileMetadata", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "DeletedBy", + schema: "Files", + table: "FileMetadata", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: true, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Files", + table: "FileMetadata", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs b/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs index 3deefd9efa..0fba03f275 100644 --- a/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Modules/Files/src/Files.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs @@ -43,9 +43,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -59,9 +59,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime2"); b.Property("DeletedBy") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("DeletedByDevice") @@ -82,9 +82,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ModifiedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("ModifiedByDevice") @@ -96,9 +96,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Owner") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("OwnerSignature") diff --git a/Modules/Messages/src/Messages.Application/ApplicationOptions.cs b/Modules/Messages/src/Messages.Application/ApplicationOptions.cs index f49a861fa2..179eaab853 100644 --- a/Modules/Messages/src/Messages.Application/ApplicationOptions.cs +++ b/Modules/Messages/src/Messages.Application/ApplicationOptions.cs @@ -4,16 +4,16 @@ namespace Backbone.Modules.Messages.Application; public class ApplicationOptions { - [Required] - [MinLength(3)] - [MaxLength(3)] - public string AddressPrefix { get; set; } = null!; - [Range(1, 100)] public int MaxNumberOfUnreceivedMessagesFromOneSender { get; set; } [Required] public PaginationOptions Pagination { get; set; } = new(); + + [Required] + [MinLength(3)] + [MaxLength(45)] + public string InstanceUrl { get; set; } = null!; } public class PaginationOptions diff --git a/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs b/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs index 802fd6c48b..d10431cbd8 100644 --- a/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs +++ b/Modules/Messages/src/Messages.Application/Messages/Commands/AnonymizeMessagesOfIdentity/Handler.cs @@ -23,7 +23,7 @@ public async Task Handle(AnonymizeMessagesOfIdentityCommand request, Cancellatio { var messages = await _messagesRepository.Find(Message.WasCreatedBy(request.IdentityAddress), cancellationToken); - var newIdentityAddress = IdentityAddress.Create(Encoding.Unicode.GetBytes(DELETED_IDENTITY_STRING), _applicationOptions.AddressPrefix); + var newIdentityAddress = IdentityAddress.Create(Encoding.Unicode.GetBytes(DELETED_IDENTITY_STRING), _applicationOptions.InstanceUrl); foreach (var message in messages) { diff --git a/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.Designer.cs b/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..ad30464a61 --- /dev/null +++ b/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.Designer.cs @@ -0,0 +1,208 @@ +// +using System; +using Backbone.Modules.Messages.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Messages.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(MessagesDbContext))] + [Migration("20240321084209_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Messages") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Attachment", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("MessageId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id", "MessageId"); + + b.HasIndex("MessageId"); + + b.ToTable("Attachments", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Message", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Body") + .HasColumnType("bytea"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("CreatedBy"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.RecipientInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("EncryptedKey") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("MessageId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ReceivedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ReceivedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("RelationshipId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("MessageId"); + + b.HasIndex("ReceivedAt"); + + b.HasIndex("RelationshipId"); + + b.HasIndex("Address", "MessageId"); + + b.ToTable("RecipientInformation"); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Relationship", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("From") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("To") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Relationships", "Relationships", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Attachment", b => + { + b.HasOne("Backbone.Modules.Messages.Domain.Entities.Message", null) + .WithMany("Attachments") + .HasForeignKey("MessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.RecipientInformation", b => + { + b.HasOne("Backbone.Modules.Messages.Domain.Entities.Message", null) + .WithMany("Recipients") + .HasForeignKey("MessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Messages.Domain.Entities.Relationship", null) + .WithMany() + .HasForeignKey("RelationshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Message", b => + { + b.Navigation("Attachments"); + + b.Navigation("Recipients"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.cs b/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.cs new file mode 100644 index 0000000000..8519fa0034 --- /dev/null +++ b/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/20240321084209_IdentityAddress80.cs @@ -0,0 +1,78 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Messages.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Address", + schema: "Messages", + table: "RecipientInformation", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Messages", + table: "Messages", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Address", + schema: "Messages", + table: "RecipientInformation", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Messages", + table: "Messages", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/MessagesDbContextModelSnapshot.cs b/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/MessagesDbContextModelSnapshot.cs index 2e1e6a1365..59d8c87ece 100644 --- a/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/MessagesDbContextModelSnapshot.cs +++ b/Modules/Messages/src/Messages.Infrastructure.Database.Postgres/Migrations/MessagesDbContextModelSnapshot.cs @@ -60,9 +60,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -89,9 +89,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Address") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("EncryptedKey") @@ -147,9 +147,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("From") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("Status") @@ -157,9 +157,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("To") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.HasKey("Id"); diff --git a/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.Designer.cs b/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..2a81fa4e65 --- /dev/null +++ b/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.Designer.cs @@ -0,0 +1,208 @@ +// +using System; +using Backbone.Modules.Messages.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Messages.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(MessagesDbContext))] + [Migration("20240321144413_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Messages") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Attachment", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("MessageId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id", "MessageId"); + + b.HasIndex("MessageId"); + + b.ToTable("Attachments", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Message", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Body") + .HasColumnType("varbinary(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("CreatedBy"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.RecipientInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("EncryptedKey") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("MessageId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ReceivedAt") + .HasColumnType("datetime2"); + + b.Property("ReceivedByDevice") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("RelationshipId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("MessageId"); + + b.HasIndex("ReceivedAt"); + + b.HasIndex("RelationshipId"); + + b.HasIndex("Address", "MessageId"); + + b.ToTable("RecipientInformation"); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Relationship", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("From") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("To") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Relationships", "Relationships", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Attachment", b => + { + b.HasOne("Backbone.Modules.Messages.Domain.Entities.Message", null) + .WithMany("Attachments") + .HasForeignKey("MessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.RecipientInformation", b => + { + b.HasOne("Backbone.Modules.Messages.Domain.Entities.Message", null) + .WithMany("Recipients") + .HasForeignKey("MessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Messages.Domain.Entities.Relationship", null) + .WithMany() + .HasForeignKey("RelationshipId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Messages.Domain.Entities.Message", b => + { + b.Navigation("Attachments"); + + b.Navigation("Recipients"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.cs b/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.cs new file mode 100644 index 0000000000..167d321503 --- /dev/null +++ b/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/20240321144413_IdentityAddress80.cs @@ -0,0 +1,78 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Messages.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Address", + schema: "Messages", + table: "RecipientInformation", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Messages", + table: "Messages", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Address", + schema: "Messages", + table: "RecipientInformation", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Messages", + table: "Messages", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs b/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs index 45570d34e8..5859b8e05e 100644 --- a/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Modules/Messages/src/Messages.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs @@ -60,9 +60,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -89,9 +89,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Address") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("EncryptedKey") @@ -147,9 +147,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("From") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("Status") @@ -157,9 +157,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("To") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.HasKey("Id"); diff --git a/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.Designer.cs b/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..00952362aa --- /dev/null +++ b/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.Designer.cs @@ -0,0 +1,351 @@ +// +using System; +using Backbone.Modules.Quotas.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Quotas.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(QuotasDbContext))] + [Migration("20240307164716_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Quotas") + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.FileMetadata.FileMetadata", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CipherSize") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("FileMetadata", "Files", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => + { + b.Property("Address") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("TierId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Address"); + + b.HasIndex("TierId"); + + b.ToTable("Identities"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.IndividualQuota", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ApplyTo") + .IsRequired() + .HasColumnType("character(80)"); + + b.Property("Max") + .HasColumnType("integer"); + + b.Property("MetricKey") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("character varying(50)") + .IsFixedLength(false); + + b.Property("Period") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ApplyTo"); + + b.ToTable("IndividualQuotas", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.MetricStatus", b => + { + b.Property("Owner") + .HasColumnType("character(80)"); + + b.Property("MetricKey") + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("character varying(50)") + .IsFixedLength(false); + + b.Property("IsExhaustedUntil") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Owner", "MetricKey"); + + b.ToTable("MetricStatuses", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.TierQuota", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ApplyTo") + .IsRequired() + .HasColumnType("character(80)"); + + b.Property("_definitionId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .HasColumnName("DefinitionId") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("ApplyTo"); + + b.HasIndex("_definitionId"); + + b.ToTable("TierQuotas", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Messages.Message", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Messages", "Messages", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Relationships.Relationship", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("From") + .IsRequired() + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("To") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Relationships", "Relationships", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Relationships.RelationshipTemplate", b => + { + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("RelationshipTemplates", "Relationships", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .IsUnicode(true) + .HasColumnType("character varying(30)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.ToTable("Tiers"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.TierQuotaDefinition", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Max") + .HasColumnType("integer"); + + b.Property("MetricKey") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("character varying(50)") + .IsFixedLength(false); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("TierId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("TierId"); + + b.ToTable("TierQuotaDefinitions", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tokens.Token", b => + { + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text"); + + b.ToTable("Tokens", "Tokens", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", null) + .WithMany() + .HasForeignKey("TierId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.IndividualQuota", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", null) + .WithMany("IndividualQuotas") + .HasForeignKey("ApplyTo") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.MetricStatus", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", null) + .WithMany("MetricStatuses") + .HasForeignKey("Owner") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.TierQuota", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", null) + .WithMany("TierQuotas") + .HasForeignKey("ApplyTo") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.TierQuotaDefinition", "_definition") + .WithMany() + .HasForeignKey("_definitionId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("_definition"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.TierQuotaDefinition", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", null) + .WithMany("Quotas") + .HasForeignKey("TierId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => + { + b.Navigation("IndividualQuotas"); + + b.Navigation("MetricStatuses"); + + b.Navigation("TierQuotas"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", b => + { + b.Navigation("Quotas"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.cs b/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.cs new file mode 100644 index 0000000000..b5ba9a37db --- /dev/null +++ b/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/20240307164716_IdentityAddress80.cs @@ -0,0 +1,241 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Quotas.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + schema: "Quotas", + name: "FK_TierQuotas_Identities_ApplyTo", + table: "TierQuotas"); + + migrationBuilder.DropForeignKey( + schema: "Quotas", + name: "FK_IndividualQuotas_Identities_ApplyTo", + table: "IndividualQuotas"); + + migrationBuilder.DropForeignKey( + schema: "Quotas", + name: "FK_MetricStatuses_Identities_Owner", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + schema: "Quotas", + name: "PK_MetricStatuses", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + schema: "Quotas", + name: "PK_Identities", + table: "Identities"); + + #region AlterColumns + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "ApplyTo", + table: "TierQuotas", + type: "character(80)", + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)"); + + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "Owner", + table: "MetricStatuses", + type: "character(80)", + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)"); + + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "ApplyTo", + table: "IndividualQuotas", + type: "character(80)", + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)"); + + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "Address", + table: "Identities", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + schema: "Quotas", + name: "PK_Identities", + table: "Identities", + column: "Address"); + + migrationBuilder.AddPrimaryKey( + schema: "Quotas", + name: "PK_MetricStatuses", + table: "MetricStatuses", + columns: new[] { "Owner", "MetricKey" }); + + migrationBuilder.AddForeignKey( + schema: "Quotas", + name: "FK_TierQuotas_Identities_ApplyTo", + table: "TierQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + schema: "Quotas", + name: "FK_MetricStatuses_Identities_Owner", + table: "MetricStatuses", + column: "Owner", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + schema: "Quotas", + name: "FK_IndividualQuotas_Identities_ApplyTo", + table: "IndividualQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + schema: "Quotas", + name: "FK_TierQuotas_Identities_ApplyTo", + table: "TierQuotas"); + + migrationBuilder.DropForeignKey( + schema: "Quotas", + name: "FK_IndividualQuotas_Identities_ApplyTo", + table: "IndividualQuotas"); + + migrationBuilder.DropForeignKey( + schema: "Quotas", + name: "FK_MetricStatuses_Identities_Owner", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + schema: "Quotas", + name: "PK_MetricStatuses", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + schema: "Quotas", + name: "PK_Identities", + table: "Identities"); + + #region AlterColumns + + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "ApplyTo", + table: "TierQuotas", + type: "character(36)", + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)"); + + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "Owner", + table: "MetricStatuses", + type: "character(36)", + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)"); + + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "ApplyTo", + table: "IndividualQuotas", + type: "character(36)", + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)"); + + migrationBuilder.AlterColumn( + schema: "Quotas", + name: "Address", + table: "Identities", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + schema: "Quotas", + name: "PK_Identities", + table: "Identities", + column: "Address"); + + migrationBuilder.AddPrimaryKey( + schema: "Quotas", + name: "PK_MetricStatuses", + table: "MetricStatuses", + columns: new[] { "Owner", "MetricKey" }); + + migrationBuilder.AddForeignKey( + schema: "Quotas", + name: "FK_TierQuotas_Identities_ApplyTo", + table: "TierQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + schema: "Quotas", + name: "FK_MetricStatuses_Identities_Owner", + table: "MetricStatuses", + column: "Owner", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + schema: "Quotas", + name: "FK_IndividualQuotas_Identities_ApplyTo", + table: "IndividualQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/QuotasDbContextModelSnapshot.cs b/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/QuotasDbContextModelSnapshot.cs index 2a891c8cd8..b53e744570 100644 --- a/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/QuotasDbContextModelSnapshot.cs +++ b/Modules/Quotas/src/Quotas.Infrastructure.Database.Postgres/Migrations/QuotasDbContextModelSnapshot.cs @@ -49,9 +49,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => { b.Property("Address") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("TierId") @@ -78,7 +78,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ApplyTo") .IsRequired() - .HasColumnType("character(36)"); + .HasColumnType("character(80)"); b.Property("Max") .HasColumnType("integer"); @@ -103,7 +103,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.MetricStatus", b => { b.Property("Owner") - .HasColumnType("character(36)"); + .HasColumnType("character(80)"); b.Property("MetricKey") .HasMaxLength(50) @@ -134,7 +134,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ApplyTo") .IsRequired() - .HasColumnType("character(36)"); + .HasColumnType("character(80)"); b.Property("_definitionId") .HasMaxLength(20) diff --git a/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.Designer.cs b/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..6f7c2e589b --- /dev/null +++ b/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.Designer.cs @@ -0,0 +1,351 @@ +// +using System; +using Backbone.Modules.Quotas.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Quotas.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(QuotasDbContext))] + [Migration("20240307154323_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Quotas") + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.FileMetadata.FileMetadata", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("CipherSize") + .HasColumnType("bigint"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("FileMetadata", "Files", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => + { + b.Property("Address") + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("TierId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Address"); + + b.HasIndex("TierId"); + + b.ToTable("Identities"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.IndividualQuota", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ApplyTo") + .IsRequired() + .HasColumnType("char(80)"); + + b.Property("Max") + .HasColumnType("int"); + + b.Property("MetricKey") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("nvarchar(50)") + .IsFixedLength(false); + + b.Property("Period") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ApplyTo"); + + b.ToTable("IndividualQuotas", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.MetricStatus", b => + { + b.Property("Owner") + .HasColumnType("char(80)"); + + b.Property("MetricKey") + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("nvarchar(50)") + .IsFixedLength(false); + + b.Property("IsExhaustedUntil") + .HasColumnType("datetime2"); + + b.HasKey("Owner", "MetricKey"); + + b.ToTable("MetricStatuses", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.TierQuota", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ApplyTo") + .IsRequired() + .HasColumnType("char(80)"); + + b.Property("_definitionId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .HasColumnName("DefinitionId") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("ApplyTo"); + + b.HasIndex("_definitionId"); + + b.ToTable("TierQuotas", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Messages.Message", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Messages", "Messages", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Relationships.Relationship", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("From") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("To") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Relationships", "Relationships", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Relationships.RelationshipTemplate", b => + { + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.ToTable("RelationshipTemplates", "Relationships", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .IsUnicode(true) + .HasColumnType("nvarchar(30)") + .IsFixedLength(false); + + b.HasKey("Id"); + + b.ToTable("Tiers"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.TierQuotaDefinition", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Max") + .HasColumnType("int"); + + b.Property("MetricKey") + .IsRequired() + .HasMaxLength(50) + .IsUnicode(true) + .HasColumnType("nvarchar(50)") + .IsFixedLength(false); + + b.Property("Period") + .HasColumnType("int"); + + b.Property("TierId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("TierId"); + + b.ToTable("TierQuotaDefinitions", (string)null); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tokens.Token", b => + { + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.ToTable("Tokens", "Tokens", t => + { + t.ExcludeFromMigrations(); + }); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", null) + .WithMany() + .HasForeignKey("TierId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.IndividualQuota", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", null) + .WithMany("IndividualQuotas") + .HasForeignKey("ApplyTo") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.MetricStatus", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", null) + .WithMany("MetricStatuses") + .HasForeignKey("Owner") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.TierQuota", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", null) + .WithMany("TierQuotas") + .HasForeignKey("ApplyTo") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.TierQuotaDefinition", "_definition") + .WithMany() + .HasForeignKey("_definitionId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("_definition"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.TierQuotaDefinition", b => + { + b.HasOne("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", null) + .WithMany("Quotas") + .HasForeignKey("TierId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => + { + b.Navigation("IndividualQuotas"); + + b.Navigation("MetricStatuses"); + + b.Navigation("TierQuotas"); + }); + + modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Tiers.Tier", b => + { + b.Navigation("Quotas"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.cs b/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.cs new file mode 100644 index 0000000000..c1b9247f73 --- /dev/null +++ b/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/20240307154323_IdentityAddress80.cs @@ -0,0 +1,239 @@ +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Quotas.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TierQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "TierQuotas"); + + migrationBuilder.DropForeignKey( + name: "FK_IndividualQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "IndividualQuotas"); + + migrationBuilder.DropForeignKey( + name: "FK_MetricStatuses_Identities_Owner", + schema: "Quotas", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MetricStatuses", + schema: "Quotas", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Identities", + schema: "Quotas", + table: "Identities"); + + #region AlterColumns + migrationBuilder.AlterColumn( + name: "ApplyTo", + schema: "Quotas", + table: "TierQuotas", + type: "char(80)", + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)"); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Quotas", + table: "MetricStatuses", + type: "char(80)", + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)"); + + migrationBuilder.AlterColumn( + name: "ApplyTo", + schema: "Quotas", + table: "IndividualQuotas", + type: "char(80)", + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)"); + + migrationBuilder.AlterColumn( + name: "Address", + schema: "Quotas", + table: "Identities", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + name: "PK_Identities", + schema: "Quotas", + table: "Identities", + column: "Address"); + + migrationBuilder.AddPrimaryKey( + name: "PK_MetricStatuses", + schema: "Quotas", + table: "MetricStatuses", + columns: new[] { "Owner", "MetricKey" }); + + migrationBuilder.AddForeignKey( + name: "FK_TierQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "TierQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_MetricStatuses_Identities_Owner", + schema: "Quotas", + table: "MetricStatuses", + column: "Owner", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_IndividualQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "IndividualQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TierQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "TierQuotas"); + + migrationBuilder.DropForeignKey( + name: "FK_IndividualQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "IndividualQuotas"); + + migrationBuilder.DropForeignKey( + name: "FK_MetricStatuses_Identities_Owner", + schema: "Quotas", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + name: "PK_MetricStatuses", + schema: "Quotas", + table: "MetricStatuses"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Identities", + schema: "Quotas", + table: "Identities"); + + #region AlterColumns + migrationBuilder.AlterColumn( + name: "ApplyTo", + schema: "Quotas", + table: "TierQuotas", + type: "char(36)", + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)"); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Quotas", + table: "MetricStatuses", + type: "char(36)", + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)"); + + migrationBuilder.AlterColumn( + name: "ApplyTo", + schema: "Quotas", + table: "IndividualQuotas", + type: "char(36)", + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)"); + + migrationBuilder.AlterColumn( + name: "Address", + schema: "Quotas", + table: "Identities", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + #endregion AlterColumns + + migrationBuilder.AddPrimaryKey( + name: "PK_Identities", + schema: "Quotas", + table: "Identities", + column: "Address"); + + migrationBuilder.AddPrimaryKey( + name: "PK_MetricStatuses", + schema: "Quotas", + table: "MetricStatuses", + columns: new[] { "Owner", "MetricKey" }); + + migrationBuilder.AddForeignKey( + name: "FK_TierQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "TierQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address"); + + migrationBuilder.AddForeignKey( + name: "FK_MetricStatuses_Identities_Owner", + schema: "Quotas", + table: "MetricStatuses", + column: "Owner", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_IndividualQuotas_Identities_ApplyTo", + schema: "Quotas", + table: "IndividualQuotas", + column: "ApplyTo", + principalTable: "Identities", + principalSchema: "Quotas", + principalColumn: "Address", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/QuotasDbContextModelSnapshot.cs b/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/QuotasDbContextModelSnapshot.cs index a8576943e1..d4ba3042bf 100644 --- a/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/QuotasDbContextModelSnapshot.cs +++ b/Modules/Quotas/src/Quotas.Infrastructure.Database.SqlServer/Migrations/QuotasDbContextModelSnapshot.cs @@ -49,9 +49,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.Identity", b => { b.Property("Address") - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("TierId") @@ -78,7 +78,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ApplyTo") .IsRequired() - .HasColumnType("char(36)"); + .HasColumnType("char(80)"); b.Property("Max") .HasColumnType("int"); @@ -103,7 +103,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Backbone.Modules.Quotas.Domain.Aggregates.Identities.MetricStatus", b => { b.Property("Owner") - .HasColumnType("char(36)"); + .HasColumnType("char(80)"); b.Property("MetricKey") .HasMaxLength(50) @@ -134,7 +134,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ApplyTo") .IsRequired() - .HasColumnType("char(36)"); + .HasColumnType("char(80)"); b.Property("_definitionId") .HasMaxLength(20) diff --git a/Modules/Quotas/test/Quotas.Application.Tests/TestDoubles/UserContextStub.cs b/Modules/Quotas/test/Quotas.Application.Tests/TestDoubles/UserContextStub.cs index b975c0b3ca..b7f54ebb80 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/TestDoubles/UserContextStub.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/TestDoubles/UserContextStub.cs @@ -7,7 +7,7 @@ internal class UserContextStub : IUserContext { public IdentityAddress GetAddress() { - return IdentityAddress.Create([0], "id1"); + return IdentityAddress.Create([0], "prod.enmeshed.eu"); } public IdentityAddress GetAddressOrNull() diff --git a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Quotas/CreateQuotaForIdentity/HandlerTests.cs b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Quotas/CreateQuotaForIdentity/HandlerTests.cs index abd45e4ed4..ef9c8cdda4 100644 --- a/Modules/Quotas/test/Quotas.Application.Tests/Tests/Quotas/CreateQuotaForIdentity/HandlerTests.cs +++ b/Modules/Quotas/test/Quotas.Application.Tests/Tests/Quotas/CreateQuotaForIdentity/HandlerTests.cs @@ -8,6 +8,7 @@ using Backbone.Modules.Quotas.Domain.Aggregates.Identities; using Backbone.Modules.Quotas.Domain.Aggregates.Metrics; using Backbone.Modules.Quotas.Domain.Aggregates.Tiers; +using Backbone.UnitTestTools.Data; using Backbone.UnitTestTools.Extensions; using FakeItEasy; using FluentAssertions; @@ -26,13 +27,13 @@ public async Task Creates_quota_for_identity() const int max = 5; const QuotaPeriod period = QuotaPeriod.Month; var metricKey = MetricKey.NumberOfSentMessages.Value; - var identityAddress = IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"); + var tierId = new TierId("TIRsomeTierId1111111"); - var command = new CreateQuotaForIdentityCommand(identityAddress, metricKey, max, period); - var identity = new Identity("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j", tierId); + var identity = new Identity(TestDataGenerator.CreateRandomIdentityAddress(), tierId); + var command = new CreateQuotaForIdentityCommand(identity.Address, metricKey, max, period); var identitiesRepository = A.Fake(); - A.CallTo(() => identitiesRepository.Find(identityAddress, A._, A._)).Returns(identity); + A.CallTo(() => identitiesRepository.Find(identity.Address, A._, A._)).Returns(identity); var metricsRepository = new FindMetricsStubRepository(new Metric(MetricKey.NumberOfSentMessages, "Number Of Sent Messages")); var handler = CreateHandler(identitiesRepository, metricsRepository); @@ -47,7 +48,7 @@ public async Task Creates_quota_for_identity() response.Metric.Key.Should().Be(metricKey); A.CallTo(() => identitiesRepository.Update(A.That.Matches(t => - t.Address == identityAddress && + t.Address == identity.Address && t.TierId == tierId && t.IndividualQuotas.Count == 1) , CancellationToken.None) @@ -58,7 +59,7 @@ public async Task Creates_quota_for_identity() public void Create_quota_with_invalid_metric_key_throws_domain_exception() { // Arrange - var command = new CreateQuotaForIdentityCommand(IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"), "An-Invalid-Metric-Key", 5, QuotaPeriod.Month); + var command = new CreateQuotaForIdentityCommand(IdentityAddress.Parse(TestDataGenerator.CreateRandomIdentityAddress()), "An-Invalid-Metric-Key", 5, QuotaPeriod.Month); var identitiesRepository = A.Fake(); var metricsRepository = new FindMetricsStubRepository(new Metric(MetricKey.NumberOfSentMessages, "Number Of Sent Messages")); var handler = CreateHandler(identitiesRepository, metricsRepository); @@ -74,7 +75,7 @@ public void Create_quota_with_invalid_metric_key_throws_domain_exception() public void Create_quota_for_non_existent_identity_throws_not_found_exception() { // Arrange - var command = new CreateQuotaForIdentityCommand(IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"), "An-Invalid-Metric-Key", 5, QuotaPeriod.Month); + var command = new CreateQuotaForIdentityCommand(IdentityAddress.Parse(TestDataGenerator.CreateRandomIdentityAddress()), "An-Invalid-Metric-Key", 5, QuotaPeriod.Month); var identitiesRepository = A.Fake(); A.CallTo(() => identitiesRepository.Find(A._, A._, A._)).Returns((Identity?)null); var metricsRepository = new FindMetricsStubRepository(new Metric(MetricKey.NumberOfSentMessages, "Number Of Sent Messages")); @@ -94,12 +95,12 @@ public async Task Updates_metric_statuses_after_creating_quota_for_identity() { // Arrange var metricKey = MetricKey.NumberOfSentMessages.Value; - var identityAddress = IdentityAddress.Parse("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j"); - var command = new CreateQuotaForIdentityCommand(identityAddress, metricKey, 5, QuotaPeriod.Month); - var identity = new Identity("id1KJnD8ipfckRQ1ivAhNVLtypmcVM5vPX4j", new TierId("TIRsomeTierId1111111")); + var tierId = new TierId("TIRsomeTierId1111111"); + var identity = new Identity(TestDataGenerator.CreateRandomIdentityAddress(), tierId); + var command = new CreateQuotaForIdentityCommand(identity.Address, metricKey, 5, QuotaPeriod.Month); var identitiesRepository = A.Fake(); - A.CallTo(() => identitiesRepository.Find(identityAddress, A._, A._)).Returns(identity); + A.CallTo(() => identitiesRepository.Find(identity.Address, A._, A._)).Returns(identity); var metricsRepository = new FindMetricsStubRepository(new Metric(MetricKey.NumberOfSentMessages, "Number Of Sent Messages")); var metricStatusesService = A.Fake(); var handler = CreateHandler(identitiesRepository, metricsRepository, metricStatusesService); @@ -109,7 +110,7 @@ public async Task Updates_metric_statuses_after_creating_quota_for_identity() // Assert A.CallTo(() => metricStatusesService.RecalculateMetricStatuses( - A>.That.Matches(x => x.Contains(identityAddress.Value)), + A>.That.Matches(x => x.Contains(identity.Address)), A>.That.Contains(metricKey), A._) ).MustHaveHappened(); diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.Designer.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..13e125b9fd --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.Designer.cs @@ -0,0 +1,250 @@ +// +using System; +using Backbone.Modules.Relationships.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(RelationshipsDbContext))] + [Migration("20240506122429_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Relationships") + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Content") + .HasColumnType("bytea"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MaxNumberOfAllocations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("RelationshipTemplates", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("AllocatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("AllocatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipTemplateId", "AllocatedBy"); + + b.ToTable("RelationshipTemplateAllocations", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreationContent") + .HasColumnType("bytea"); + + b.Property("CreationResponseContent") + .HasColumnType("bytea"); + + b.Property("From") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("To") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("From"); + + b.HasIndex("RelationshipTemplateId"); + + b.HasIndex("To"); + + b.ToTable("Relationships", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("NewStatus") + .HasColumnType("integer"); + + b.Property("OldStatus") + .HasColumnType("integer"); + + b.Property("Reason") + .HasColumnType("integer"); + + b.Property("RelationshipId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipId"); + + b.ToTable("RelationshipAuditLog", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", null) + .WithMany("Allocations") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", "RelationshipTemplate") + .WithMany("Relationships") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("RelationshipTemplate"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", null) + .WithMany("AuditLog") + .HasForeignKey("RelationshipId"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Navigation("Allocations"); + + b.Navigation("Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Navigation("AuditLog"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.cs new file mode 100644 index 0000000000..1e1212f5d5 --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/20240506122429_IdentityAddress80.cs @@ -0,0 +1,168 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipTemplates", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "AllocatedBy", + schema: "Relationships", + table: "RelationshipTemplateAllocations", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "To", + schema: "Relationships", + table: "Relationships", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "From", + schema: "Relationships", + table: "Relationships", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipAuditLog", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipTemplates", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "AllocatedBy", + schema: "Relationships", + table: "RelationshipTemplateAllocations", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "To", + schema: "Relationships", + table: "Relationships", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "From", + schema: "Relationships", + table: "Relationships", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipAuditLog", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs index 54d1162bc1..2b883a5891 100644 --- a/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.Postgres/Migrations/RelationshipsDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Relationships") - .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("ProductVersion", "8.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -39,9 +39,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -78,9 +78,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AllocatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("AllocatedByDevice") @@ -123,9 +123,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("From") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("RelationshipTemplateId") @@ -140,9 +140,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("To") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.HasKey("Id"); @@ -169,9 +169,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.Designer.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..5426434785 --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.Designer.cs @@ -0,0 +1,250 @@ +// +using System; +using Backbone.Modules.Relationships.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(RelationshipsDbContext))] + [Migration("20240506122507_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Relationships") + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Content") + .HasColumnType("varbinary(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DeletedAt") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("MaxNumberOfAllocations") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("RelationshipTemplates", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AllocatedAt") + .HasColumnType("datetime2"); + + b.Property("AllocatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("AllocatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipTemplateId", "AllocatedBy"); + + b.ToTable("RelationshipTemplateAllocations", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreationContent") + .HasColumnType("varbinary(max)"); + + b.Property("CreationResponseContent") + .HasColumnType("varbinary(max)"); + + b.Property("From") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("RelationshipTemplateId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("To") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("From"); + + b.HasIndex("RelationshipTemplateId"); + + b.HasIndex("To"); + + b.ToTable("Relationships", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("NewStatus") + .HasColumnType("int"); + + b.Property("OldStatus") + .HasColumnType("int"); + + b.Property("Reason") + .HasColumnType("int"); + + b.Property("RelationshipId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("RelationshipId"); + + b.ToTable("RelationshipAuditLog", "Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplateAllocation", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", null) + .WithMany("Allocations") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", "RelationshipTemplate") + .WithMany("Relationships") + .HasForeignKey("RelationshipTemplateId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("RelationshipTemplate"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.RelationshipAuditLogEntry", b => + { + b.HasOne("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", null) + .WithMany("AuditLog") + .HasForeignKey("RelationshipId"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates.RelationshipTemplate", b => + { + b.Navigation("Allocations"); + + b.Navigation("Relationships"); + }); + + modelBuilder.Entity("Backbone.Modules.Relationships.Domain.Aggregates.Relationships.Relationship", b => + { + b.Navigation("AuditLog"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.cs new file mode 100644 index 0000000000..67a845bbf9 --- /dev/null +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/20240506122507_IdentityAddress80.cs @@ -0,0 +1,168 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Relationships.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipTemplates", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "AllocatedBy", + schema: "Relationships", + table: "RelationshipTemplateAllocations", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "To", + schema: "Relationships", + table: "Relationships", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "From", + schema: "Relationships", + table: "Relationships", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipAuditLog", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipTemplates", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "AllocatedBy", + schema: "Relationships", + table: "RelationshipTemplateAllocations", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "To", + schema: "Relationships", + table: "Relationships", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "From", + schema: "Relationships", + table: "Relationships", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Relationships", + table: "RelationshipAuditLog", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs index e85e469e14..65ff4d7724 100644 --- a/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs +++ b/Modules/Relationships/src/Relationships.Infrastructure.Database.SqlServer/Migrations/RelationshipsDbContextModelSnapshot.cs @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("Relationships") - .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("ProductVersion", "8.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -39,9 +39,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -78,9 +78,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AllocatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("AllocatedByDevice") @@ -123,9 +123,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("From") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("RelationshipTemplateId") @@ -140,9 +140,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("To") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.HasKey("Id"); @@ -169,9 +169,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/Modules/Relationships/test/Relationships.Application.Tests/Extensions/RelationshipTemplateQueryableExtensionsTests.cs b/Modules/Relationships/test/Relationships.Application.Tests/Extensions/RelationshipTemplateQueryableExtensionsTests.cs index 1403be10fc..276a099aeb 100644 --- a/Modules/Relationships/test/Relationships.Application.Tests/Extensions/RelationshipTemplateQueryableExtensionsTests.cs +++ b/Modules/Relationships/test/Relationships.Application.Tests/Extensions/RelationshipTemplateQueryableExtensionsTests.cs @@ -27,8 +27,8 @@ public RelationshipTemplateQueryableExtensionsTests() public void NotExpiredFor_DoesNotFilterOutTemplatesForParticipants() { // Arrange - var templateCreator = IdentityAddress.Create(new byte[2], "id0"); - var requestCreator = IdentityAddress.Create(new byte[5], "id0"); + var templateCreator = UnitTestTools.Data.TestDataGenerator.CreateRandomIdentityAddress(); + var requestCreator = UnitTestTools.Data.TestDataGenerator.CreateRandomIdentityAddress(); var template = new RelationshipTemplate(templateCreator, DeviceId.New(), 1, YESTERDAY, new byte[2]); var relationship = new Relationship(template, requestCreator, DeviceId.New(), new byte[2], []); diff --git a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.Designer.cs b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..1cc6c0d94c --- /dev/null +++ b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.Designer.cs @@ -0,0 +1,325 @@ +// +using System; +using Backbone.Modules.Synchronization.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Synchronization.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(SynchronizationDbContext))] + [Migration("20240321083947_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Synchronization") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Datawallet", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("Version") + .IsUnicode(false) + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Owner") + .IsUnique(); + + b.ToTable("Datawallets"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.DatawalletModification", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("BlobReference") + .IsRequired() + .HasMaxLength(32) + .IsUnicode(false) + .HasColumnType("character(32)") + .IsFixedLength(); + + b.Property("Collection") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DatawalletId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("DatawalletVersion") + .IsUnicode(false) + .HasColumnType("integer"); + + b.Property("EncryptedPayload") + .HasColumnType("bytea"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("ObjectIdentifier") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("PayloadCategory") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("DatawalletId"); + + b.HasIndex("CreatedBy", "Index") + .IsUnique(); + + b.ToTable("DatawalletModifications"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("Payload") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("SyncErrorCount") + .HasColumnType("smallint"); + + b.Property("SyncRunId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("SyncRunId"); + + b.HasIndex("Owner", "Index") + .IsUnique(); + + b.HasIndex("Owner", "SyncRunId"); + + b.ToTable("ExternalEvents"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncError", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ErrorCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ExternalEventId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("SyncRunId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("ExternalEventId"); + + b.HasIndex("SyncRunId", "ExternalEventId") + .IsUnique(); + + b.ToTable("SyncErrors"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("EventCount") + .HasColumnType("integer"); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FinalizedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("CreatedBy", "FinalizedAt"); + + b.HasIndex("CreatedBy", "Index") + .IsUnique(); + + b.ToTable("SyncRuns"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.DatawalletModification", b => + { + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Datawallet", "Datawallet") + .WithMany("Modifications") + .HasForeignKey("DatawalletId"); + + b.Navigation("Datawallet"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", b => + { + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", "SyncRun") + .WithMany("ExternalEvents") + .HasForeignKey("SyncRunId"); + + b.Navigation("SyncRun"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncError", b => + { + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", null) + .WithMany("Errors") + .HasForeignKey("ExternalEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", null) + .WithMany("Errors") + .HasForeignKey("SyncRunId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Datawallet", b => + { + b.Navigation("Modifications"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", b => + { + b.Navigation("Errors"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", b => + { + b.Navigation("Errors"); + + b.Navigation("ExternalEvents"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.cs b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.cs new file mode 100644 index 0000000000..6caeb1c804 --- /dev/null +++ b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/20240321083947_IdentityAddress80.cs @@ -0,0 +1,138 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Synchronization.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "SyncRuns", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "ExternalEvents", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "Datawallets", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "DatawalletModifications", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "SyncRuns", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "ExternalEvents", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "Datawallets", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "DatawalletModifications", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/SynchronizationDbContextModelSnapshot.cs b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/SynchronizationDbContextModelSnapshot.cs index 6dfe417635..d0e653efe7 100644 --- a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/SynchronizationDbContextModelSnapshot.cs +++ b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.Postgres/Migrations/SynchronizationDbContextModelSnapshot.cs @@ -33,9 +33,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Owner") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("Version") @@ -75,9 +75,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -141,9 +141,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Owner") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("Payload") @@ -226,9 +226,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.Designer.cs b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..c559daf169 --- /dev/null +++ b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.Designer.cs @@ -0,0 +1,325 @@ +// +using System; +using Backbone.Modules.Synchronization.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Synchronization.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(SynchronizationDbContext))] + [Migration("20240321144459_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Synchronization") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Datawallet", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("Version") + .IsUnicode(false) + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Owner") + .IsUnique(); + + b.ToTable("Datawallets"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.DatawalletModification", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("BlobReference") + .IsRequired() + .HasMaxLength(32) + .IsUnicode(false) + .HasColumnType("char(32)") + .IsFixedLength(); + + b.Property("Collection") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DatawalletId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("DatawalletVersion") + .IsUnicode(false) + .HasColumnType("int"); + + b.Property("EncryptedPayload") + .HasColumnType("varbinary(max)"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("ObjectIdentifier") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("PayloadCategory") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("DatawalletId"); + + b.HasIndex("CreatedBy", "Index") + .IsUnique(); + + b.ToTable("DatawalletModifications"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("Owner") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("Payload") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("SyncErrorCount") + .HasColumnType("tinyint"); + + b.Property("SyncRunId") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SyncRunId"); + + b.HasIndex("Owner", "Index") + .IsUnique(); + + b.HasIndex("Owner", "SyncRunId"); + + b.ToTable("ExternalEvents"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncError", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ErrorCode") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ExternalEventId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("SyncRunId") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.HasIndex("ExternalEventId"); + + b.HasIndex("SyncRunId", "ExternalEventId") + .IsUnique(); + + b.ToTable("SyncErrors"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("EventCount") + .HasColumnType("int"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("FinalizedAt") + .HasColumnType("datetime2"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("CreatedBy", "FinalizedAt"); + + b.HasIndex("CreatedBy", "Index") + .IsUnique(); + + b.ToTable("SyncRuns"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.DatawalletModification", b => + { + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Datawallet", "Datawallet") + .WithMany("Modifications") + .HasForeignKey("DatawalletId"); + + b.Navigation("Datawallet"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", b => + { + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", "SyncRun") + .WithMany("ExternalEvents") + .HasForeignKey("SyncRunId"); + + b.Navigation("SyncRun"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncError", b => + { + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", null) + .WithMany("Errors") + .HasForeignKey("ExternalEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", null) + .WithMany("Errors") + .HasForeignKey("SyncRunId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Datawallet", b => + { + b.Navigation("Modifications"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.ExternalEvent", b => + { + b.Navigation("Errors"); + }); + + modelBuilder.Entity("Backbone.Modules.Synchronization.Domain.Entities.Sync.SyncRun", b => + { + b.Navigation("Errors"); + + b.Navigation("ExternalEvents"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.cs b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.cs new file mode 100644 index 0000000000..5eb8bded44 --- /dev/null +++ b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/20240321144459_IdentityAddress80.cs @@ -0,0 +1,138 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Synchronization.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "SyncRuns", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "ExternalEvents", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "Datawallets", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "DatawalletModifications", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "SyncRuns", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "ExternalEvents", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "Owner", + schema: "Synchronization", + table: "Datawallets", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Synchronization", + table: "DatawalletModifications", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs index 89b718ef50..9537e45219 100644 --- a/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Modules/Synchronization/src/Synchronization.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs @@ -33,9 +33,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Owner") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("Version") @@ -75,9 +75,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") @@ -141,9 +141,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Owner") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("Payload") @@ -226,9 +226,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/Modules/Synchronization/test/Synchronization.Application.Tests/TestDataGenerator.cs b/Modules/Synchronization/test/Synchronization.Application.Tests/TestDataGenerator.cs index 865acbcd68..d998d1fca4 100644 --- a/Modules/Synchronization/test/Synchronization.Application.Tests/TestDataGenerator.cs +++ b/Modules/Synchronization/test/Synchronization.Application.Tests/TestDataGenerator.cs @@ -6,7 +6,7 @@ public static class TestDataGenerator { public static IdentityAddress CreateRandomIdentityAddress() { - return IdentityAddress.Create(CreateRandomBytes(), "id1"); + return IdentityAddress.Create(CreateRandomBytes(), "prod.enmeshed.eu"); } public static DeviceId CreateRandomDeviceId() diff --git a/Modules/Synchronization/test/Synchronization.Domain.Tests/TestDataGenerator.cs b/Modules/Synchronization/test/Synchronization.Domain.Tests/TestDataGenerator.cs index 8a9b3290f1..1a566a3a25 100644 --- a/Modules/Synchronization/test/Synchronization.Domain.Tests/TestDataGenerator.cs +++ b/Modules/Synchronization/test/Synchronization.Domain.Tests/TestDataGenerator.cs @@ -6,7 +6,7 @@ public static class TestDataGenerator { public static IdentityAddress CreateRandomIdentityAddress() { - return IdentityAddress.Create(CreateRandomBytes(), "id1"); + return IdentityAddress.Create(CreateRandomBytes(), "prod.enmeshed.eu"); } public static DeviceId CreateRandomDeviceId() diff --git a/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.Designer.cs b/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..a0d1a5a0fa --- /dev/null +++ b/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.Designer.cs @@ -0,0 +1,69 @@ +// +using System; +using Backbone.Modules.Tokens.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Backbone.Modules.Tokens.Infrastructure.Database.Postgres.Migrations +{ + [DbContext(typeof(TokensDbContext))] + [Migration("20240321084133_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Tokens") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Tokens.Domain.Entities.Token", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("Content") + .HasColumnType("bytea"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("character(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("character(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.ToTable("Tokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.cs b/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.cs new file mode 100644 index 0000000000..ed054652cd --- /dev/null +++ b/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/20240321084133_IdentityAddress80.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Tokens.Infrastructure.Database.Postgres.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Tokens", + table: "Tokens", + type: "character(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "character(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Tokens", + table: "Tokens", + type: "character(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "character(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/TokensDbContextModelSnapshot.cs b/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/TokensDbContextModelSnapshot.cs index 6d27d26a39..0d042bfb08 100644 --- a/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/TokensDbContextModelSnapshot.cs +++ b/Modules/Tokens/src/Tokens.Infrastructure.Database.Postgres/Migrations/TokensDbContextModelSnapshot.cs @@ -39,9 +39,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("character(36)") + .HasColumnType("character(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.Designer.cs b/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.Designer.cs new file mode 100644 index 0000000000..cd9242d043 --- /dev/null +++ b/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.Designer.cs @@ -0,0 +1,69 @@ +// +using System; +using Backbone.Modules.Tokens.Infrastructure.Persistence.Database; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Backbone.Modules.Tokens.Infrastructure.Database.SqlServer.Migrations +{ + [DbContext(typeof(TokensDbContext))] + [Migration("20240321144548_IdentityAddress80")] + partial class IdentityAddress80 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Tokens") + .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Backbone.Modules.Tokens.Domain.Entities.Token", b => + { + b.Property("Id") + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("Content") + .HasColumnType("varbinary(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(80) + .IsUnicode(false) + .HasColumnType("char(80)") + .IsFixedLength(); + + b.Property("CreatedByDevice") + .IsRequired() + .HasMaxLength(20) + .IsUnicode(false) + .HasColumnType("char(20)") + .IsFixedLength(); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.ToTable("Tokens"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.cs b/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.cs new file mode 100644 index 0000000000..a71a660de9 --- /dev/null +++ b/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/20240321144548_IdentityAddress80.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Backbone.Modules.Tokens.Infrastructure.Database.SqlServer.Migrations +{ + /// + public partial class IdentityAddress80 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Tokens", + table: "Tokens", + type: "char(80)", + unicode: false, + fixedLength: true, + maxLength: 80, + nullable: false, + oldClrType: typeof(string), + oldType: "char(36)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 36); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "CreatedBy", + schema: "Tokens", + table: "Tokens", + type: "char(36)", + unicode: false, + fixedLength: true, + maxLength: 36, + nullable: false, + oldClrType: typeof(string), + oldType: "char(80)", + oldUnicode: false, + oldFixedLength: true, + oldMaxLength: 80); + } + } +} diff --git a/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs b/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs index 5751de1941..c60484356b 100644 --- a/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/Modules/Tokens/src/Tokens.Infrastructure.Database.SqlServer/Migrations/ApplicationDbContextModelSnapshot.cs @@ -39,9 +39,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedBy") .IsRequired() - .HasMaxLength(36) + .HasMaxLength(80) .IsUnicode(false) - .HasColumnType("char(36)") + .HasColumnType("char(80)") .IsFixedLength(); b.Property("CreatedByDevice") diff --git a/docker-compose/adminui.appsettings.override.json b/docker-compose/adminui.appsettings.override.json index 7a03fc453c..239ff696f5 100644 --- a/docker-compose/adminui.appsettings.override.json +++ b/docker-compose/adminui.appsettings.override.json @@ -31,7 +31,6 @@ "Modules": { "Devices": { "Application": { - "AddressPrefix": "id1", "Pagination": { "DefaultPageSize": 50, "MaxPageSize": 200