From 11b6b3e5d3b4c5001c6f918d923651b18d1ab7d9 Mon Sep 17 00:00:00 2001 From: Iliyan Iliev Date: Wed, 1 Jul 2020 10:26:21 +0300 Subject: [PATCH] Closes #11 --- ...N.Service.CustomerManagement.Client.csproj | 4 +- ...N.Service.CustomerManagement.Domain.csproj | 2 +- ...e.CustomerManagement.DomainServices.csproj | 14 +-- .../Contexts/CmContext.cs | 8 +- ...ustomerManagement.MsSqlRepositories.csproj | 9 +- .../20190610091228_Initial.Designer.cs | 51 --------- .../Migrations/20190610091228_Initial.cs | 44 -------- ...190610125127_AddRequiredFields.Designer.cs | 51 --------- .../20190610125127_AddRequiredFields.cs | 53 --------- .../20190724075532_CustomerFlags.Designer.cs | 65 ----------- .../20190724075532_CustomerFlags.cs | 30 ------ ...tomersRegistrationReferralInfo.Designer.cs | 80 -------------- ...40_AddCustomersRegistrationReferralInfo.cs | 30 ------ ...ficationCodesTableAndAddNewOneForPhones.cs | 44 -------- ...romPhoneVerificationCodeEntity.Designer.cs | 101 ----------------- ...VerifiedFromPhoneVerificationCodeEntity.cs | 25 ----- ....cs => 20200701072112_Initial.Designer.cs} | 54 +++++----- .../Migrations/20200701072112_Initial.cs | 102 ++++++++++++++++++ .../Migrations/CmContextModelSnapshot.cs | 47 ++++---- .../Repositories/CustomerFlagsRepository.cs | 13 +-- ...omersRegistrationReferralDataRepository.cs | 13 +-- .../EmailVerificationCodeRepository.cs | 13 +-- .../PhoneVerificationCodeRepository.cs | 13 +-- .../Dockerfile | 2 +- .../MAVN.Service.CustomerManagement.csproj | 10 +- .../Modules/DataModule.cs | 6 +- ...VN.Service.CustomerManagement.Tests.csproj | 14 +-- 27 files changed, 224 insertions(+), 674 deletions(-) delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.Designer.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.Designer.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.Designer.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.Designer.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.Designer.cs delete mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.cs rename src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/{20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.Designer.cs => 20200701072112_Initial.Designer.cs} (64%) create mode 100644 src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20200701072112_Initial.cs diff --git a/client/MAVN.Service.CustomerManagement.Client/MAVN.Service.CustomerManagement.Client.csproj b/client/MAVN.Service.CustomerManagement.Client/MAVN.Service.CustomerManagement.Client.csproj index 2d180f8..64dcc42 100644 --- a/client/MAVN.Service.CustomerManagement.Client/MAVN.Service.CustomerManagement.Client.csproj +++ b/client/MAVN.Service.CustomerManagement.Client/MAVN.Service.CustomerManagement.Client.csproj @@ -14,8 +14,8 @@ - - + + \ No newline at end of file diff --git a/src/MAVN.Service.CustomerManagement.Domain/MAVN.Service.CustomerManagement.Domain.csproj b/src/MAVN.Service.CustomerManagement.Domain/MAVN.Service.CustomerManagement.Domain.csproj index 3f8ddb3..d893ad4 100644 --- a/src/MAVN.Service.CustomerManagement.Domain/MAVN.Service.CustomerManagement.Domain.csproj +++ b/src/MAVN.Service.CustomerManagement.Domain/MAVN.Service.CustomerManagement.Domain.csproj @@ -1,6 +1,6 @@ - netcoreapp2.2 + netcoreapp3.1 1.0.0 diff --git a/src/MAVN.Service.CustomerManagement.DomainServices/MAVN.Service.CustomerManagement.DomainServices.csproj b/src/MAVN.Service.CustomerManagement.DomainServices/MAVN.Service.CustomerManagement.DomainServices.csproj index ba4f624..03b867b 100644 --- a/src/MAVN.Service.CustomerManagement.DomainServices/MAVN.Service.CustomerManagement.DomainServices.csproj +++ b/src/MAVN.Service.CustomerManagement.DomainServices/MAVN.Service.CustomerManagement.DomainServices.csproj @@ -1,18 +1,18 @@ - netcoreapp2.2 + netcoreapp3.1 1.0.0 - - - + + + - - + + - + diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Contexts/CmContext.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Contexts/CmContext.cs index c1564d0..98fc653 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Contexts/CmContext.cs +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Contexts/CmContext.cs @@ -1,11 +1,11 @@ -using System.Data.Common; -using MAVN.Common.MsSql; +using System.Data.Common; +using MAVN.Persistence.PostgreSQL.Legacy; using MAVN.Service.CustomerManagement.MsSqlRepositories.Entities; using Microsoft.EntityFrameworkCore; namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts { - public class CmContext : MsSqlContext + public class CmContext : PostgreSQLContext { private const string Schema = "customer_management"; @@ -31,7 +31,7 @@ public CmContext(DbConnection dbConnection) { } - protected override void OnLykkeModelCreating(ModelBuilder modelBuilder) + protected override void OnMAVNModelCreating(ModelBuilder modelBuilder) { var verificationCodeEntityBuilder = modelBuilder.Entity(); verificationCodeEntityBuilder.HasIndex(c => c.VerificationCode).IsUnique(); diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/MAVN.Service.CustomerManagement.MsSqlRepositories.csproj b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/MAVN.Service.CustomerManagement.MsSqlRepositories.csproj index d530b0f..342f74a 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/MAVN.Service.CustomerManagement.MsSqlRepositories.csproj +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/MAVN.Service.CustomerManagement.MsSqlRepositories.csproj @@ -1,13 +1,16 @@ - netcoreapp2.2 + netcoreapp3.1 1.0.0 MAVN.Service.CustomerManagement.MsSqlRepositories - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.Designer.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.Designer.cs deleted file mode 100644 index 3766a1d..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.Designer.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System; -using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - [DbContext(typeof(CmContext))] - [Migration("20190610091228_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("customer_management") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.VerificationCodeEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ExpireDate") - .HasColumnName("expire_date"); - - b.Property("IsVerified") - .HasColumnName("is_verified"); - - b.Property("VerificationCode") - .HasColumnName("code"); - - b.HasKey("CustomerId"); - - b.HasIndex("VerificationCode") - .IsUnique() - .HasFilter("[code] IS NOT NULL"); - - b.ToTable("verification_codes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.cs deleted file mode 100644 index 6a2e09d..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610091228_Initial.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - public partial class Initial : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "customer_management"); - - migrationBuilder.CreateTable( - name: "verification_codes", - schema: "customer_management", - columns: table => new - { - customer_id = table.Column(nullable: false), - code = table.Column(nullable: true), - is_verified = table.Column(nullable: false), - expire_date = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_verification_codes", x => x.customer_id); - }); - - migrationBuilder.CreateIndex( - name: "IX_verification_codes_code", - schema: "customer_management", - table: "verification_codes", - column: "code", - unique: true, - filter: "[code] IS NOT NULL"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "verification_codes", - schema: "customer_management"); - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.Designer.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.Designer.cs deleted file mode 100644 index 8650fd7..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.Designer.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System; -using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - [DbContext(typeof(CmContext))] - [Migration("20190610125127_AddRequiredFields")] - partial class AddRequiredFields - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("customer_management") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.VerificationCodeEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ExpireDate") - .HasColumnName("expire_date"); - - b.Property("IsVerified") - .HasColumnName("is_verified"); - - b.Property("VerificationCode") - .IsRequired() - .HasColumnName("code"); - - b.HasKey("CustomerId"); - - b.HasIndex("VerificationCode") - .IsUnique(); - - b.ToTable("verification_codes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.cs deleted file mode 100644 index b7e0c5e..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190610125127_AddRequiredFields.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - public partial class AddRequiredFields : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_verification_codes_code", - schema: "customer_management", - table: "verification_codes"); - - migrationBuilder.AlterColumn( - name: "code", - schema: "customer_management", - table: "verification_codes", - nullable: false, - oldClrType: typeof(string), - oldNullable: true); - - migrationBuilder.CreateIndex( - name: "IX_verification_codes_code", - schema: "customer_management", - table: "verification_codes", - column: "code", - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_verification_codes_code", - schema: "customer_management", - table: "verification_codes"); - - migrationBuilder.AlterColumn( - name: "code", - schema: "customer_management", - table: "verification_codes", - nullable: true, - oldClrType: typeof(string)); - - migrationBuilder.CreateIndex( - name: "IX_verification_codes_code", - schema: "customer_management", - table: "verification_codes", - column: "code", - unique: true, - filter: "[code] IS NOT NULL"); - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.Designer.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.Designer.cs deleted file mode 100644 index afe5c1a..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.Designer.cs +++ /dev/null @@ -1,65 +0,0 @@ -// -using System; -using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - [DbContext(typeof(CmContext))] - [Migration("20190724075532_CustomerFlags")] - partial class CustomerFlags - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("customer_management") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerFlagsEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("IsBlocked") - .HasColumnName("is_blocked"); - - b.HasKey("CustomerId"); - - b.ToTable("customer_flags"); - }); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.VerificationCodeEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ExpireDate") - .HasColumnName("expire_date"); - - b.Property("IsVerified") - .HasColumnName("is_verified"); - - b.Property("VerificationCode") - .IsRequired() - .HasColumnName("code"); - - b.HasKey("CustomerId"); - - b.HasIndex("VerificationCode") - .IsUnique(); - - b.ToTable("verification_codes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.cs deleted file mode 100644 index d21c35d..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190724075532_CustomerFlags.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - public partial class CustomerFlags : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "customer_flags", - schema: "customer_management", - columns: table => new - { - customer_id = table.Column(nullable: false), - is_blocked = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_customer_flags", x => x.customer_id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "customer_flags", - schema: "customer_management"); - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.Designer.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.Designer.cs deleted file mode 100644 index 75f4afe..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.Designer.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -using System; -using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - [DbContext(typeof(CmContext))] - [Migration("20190827103040_AddCustomersRegistrationReferralInfo")] - partial class AddCustomersRegistrationReferralInfo - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("customer_management") - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerFlagsEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("IsBlocked") - .HasColumnName("is_blocked"); - - b.HasKey("CustomerId"); - - b.ToTable("customer_flags"); - }); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerRegistrationReferralDataEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ReferralCode") - .IsRequired() - .HasColumnName("referral_code"); - - b.HasKey("CustomerId"); - - b.ToTable("customers_registration_referral_data"); - }); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.VerificationCodeEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ExpireDate") - .HasColumnName("expire_date"); - - b.Property("IsVerified") - .HasColumnName("is_verified"); - - b.Property("VerificationCode") - .IsRequired() - .HasColumnName("code"); - - b.HasKey("CustomerId"); - - b.HasIndex("VerificationCode") - .IsUnique(); - - b.ToTable("verification_codes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.cs deleted file mode 100644 index 6ca4fe7..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20190827103040_AddCustomersRegistrationReferralInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - public partial class AddCustomersRegistrationReferralInfo : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "customers_registration_referral_data", - schema: "customer_management", - columns: table => new - { - customer_id = table.Column(nullable: false), - referral_code = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_customers_registration_referral_data", x => x.customer_id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "customers_registration_referral_data", - schema: "customer_management"); - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.cs deleted file mode 100644 index b4523a3..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - public partial class RenameVerificationCodesTableAndAddNewOneForPhones : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameTable("verification_codes", "customer_management", "email_verification_codes", "customer_management"); - - migrationBuilder.CreateTable( - name: "phone_verification_codes", - schema: "customer_management", - columns: table => new - { - customer_id = table.Column(nullable: false), - code = table.Column(nullable: false), - is_verified = table.Column(nullable: false), - expire_date = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_phone_verification_codes", x => x.customer_id); - }); - - migrationBuilder.CreateIndex( - name: "IX_phone_verification_codes_customer_id_code", - schema: "customer_management", - table: "phone_verification_codes", - columns: new[] { "customer_id", "code" }, - unique: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameTable("email_verification_codes", "customer_management", "verification_codes", "customer_management"); - - migrationBuilder.DropTable( - name: "phone_verification_codes", - schema: "customer_management"); - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.Designer.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.Designer.cs deleted file mode 100644 index 8f274bd..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.Designer.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -using System; -using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - [DbContext(typeof(CmContext))] - [Migration("20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity")] - partial class RemoveIsVerifiedFromPhoneVerificationCodeEntity - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("customer_management") - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerFlagsEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("IsBlocked") - .HasColumnName("is_blocked"); - - b.HasKey("CustomerId"); - - b.ToTable("customer_flags"); - }); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerRegistrationReferralDataEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ReferralCode") - .IsRequired() - .HasColumnName("referral_code"); - - b.HasKey("CustomerId"); - - b.ToTable("customers_registration_referral_data"); - }); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.EmailVerificationCodeEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ExpireDate") - .HasColumnName("expire_date"); - - b.Property("IsVerified") - .HasColumnName("is_verified"); - - b.Property("VerificationCode") - .IsRequired() - .HasColumnName("code"); - - b.HasKey("CustomerId"); - - b.HasIndex("VerificationCode") - .IsUnique(); - - b.ToTable("email_verification_codes"); - }); - - modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.PhoneVerificationCodeEntity", b => - { - b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); - - b.Property("ExpireDate") - .HasColumnName("expire_date"); - - b.Property("VerificationCode") - .IsRequired() - .HasColumnName("code"); - - b.HasKey("CustomerId"); - - b.HasIndex("CustomerId", "VerificationCode") - .IsUnique(); - - b.ToTable("phone_verification_codes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.cs deleted file mode 100644 index 0dcf428..0000000 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191007083546_RemoveIsVerifiedFromPhoneVerificationCodeEntity.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations -{ - public partial class RemoveIsVerifiedFromPhoneVerificationCodeEntity : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "is_verified", - schema: "customer_management", - table: "phone_verification_codes"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "is_verified", - schema: "customer_management", - table: "phone_verification_codes", - nullable: false, - defaultValue: false); - } - } -} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.Designer.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20200701072112_Initial.Designer.cs similarity index 64% rename from src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.Designer.cs rename to src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20200701072112_Initial.Designer.cs index 68be3cc..68d437b 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones.Designer.cs +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20200701072112_Initial.Designer.cs @@ -1,35 +1,36 @@ -// +// using System; using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations { [DbContext(typeof(CmContext))] - [Migration("20191003140538_RenameVerificationCodesTableAndAddNewOneForPhones")] - partial class RenameVerificationCodesTableAndAddNewOneForPhones + [Migration("20200701072112_Initial")] + partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("customer_management") - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) + .HasAnnotation("ProductVersion", "3.1.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerFlagsEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("IsBlocked") - .HasColumnName("is_blocked"); + .HasColumnName("is_blocked") + .HasColumnType("boolean"); b.HasKey("CustomerId"); @@ -39,12 +40,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerRegistrationReferralDataEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("ReferralCode") .IsRequired() - .HasColumnName("referral_code"); + .HasColumnName("referral_code") + .HasColumnType("text"); b.HasKey("CustomerId"); @@ -54,18 +56,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.EmailVerificationCodeEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("ExpireDate") - .HasColumnName("expire_date"); + .HasColumnName("expire_date") + .HasColumnType("timestamp without time zone"); b.Property("IsVerified") - .HasColumnName("is_verified"); + .HasColumnName("is_verified") + .HasColumnType("boolean"); b.Property("VerificationCode") .IsRequired() - .HasColumnName("code"); + .HasColumnName("code") + .HasColumnType("text"); b.HasKey("CustomerId"); @@ -78,18 +83,17 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.PhoneVerificationCodeEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("ExpireDate") - .HasColumnName("expire_date"); - - b.Property("IsVerified") - .HasColumnName("is_verified"); + .HasColumnName("expire_date") + .HasColumnType("timestamp without time zone"); b.Property("VerificationCode") .IsRequired() - .HasColumnName("code"); + .HasColumnName("code") + .HasColumnType("text"); b.HasKey("CustomerId"); diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20200701072112_Initial.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20200701072112_Initial.cs new file mode 100644 index 0000000..c1810df --- /dev/null +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/20200701072112_Initial.cs @@ -0,0 +1,102 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations +{ + public partial class Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "customer_management"); + + migrationBuilder.CreateTable( + name: "customer_flags", + schema: "customer_management", + columns: table => new + { + customer_id = table.Column(nullable: false), + is_blocked = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_customer_flags", x => x.customer_id); + }); + + migrationBuilder.CreateTable( + name: "customers_registration_referral_data", + schema: "customer_management", + columns: table => new + { + customer_id = table.Column(nullable: false), + referral_code = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_customers_registration_referral_data", x => x.customer_id); + }); + + migrationBuilder.CreateTable( + name: "email_verification_codes", + schema: "customer_management", + columns: table => new + { + customer_id = table.Column(nullable: false), + code = table.Column(nullable: false), + is_verified = table.Column(nullable: false), + expire_date = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_email_verification_codes", x => x.customer_id); + }); + + migrationBuilder.CreateTable( + name: "phone_verification_codes", + schema: "customer_management", + columns: table => new + { + customer_id = table.Column(nullable: false), + code = table.Column(nullable: false), + expire_date = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_phone_verification_codes", x => x.customer_id); + }); + + migrationBuilder.CreateIndex( + name: "IX_email_verification_codes_code", + schema: "customer_management", + table: "email_verification_codes", + column: "code", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_phone_verification_codes_customer_id_code", + schema: "customer_management", + table: "phone_verification_codes", + columns: new[] { "customer_id", "code" }, + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "customer_flags", + schema: "customer_management"); + + migrationBuilder.DropTable( + name: "customers_registration_referral_data", + schema: "customer_management"); + + migrationBuilder.DropTable( + name: "email_verification_codes", + schema: "customer_management"); + + migrationBuilder.DropTable( + name: "phone_verification_codes", + schema: "customer_management"); + } + } +} diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/CmContextModelSnapshot.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/CmContextModelSnapshot.cs index 59231e3..588cb09 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/CmContextModelSnapshot.cs +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Migrations/CmContextModelSnapshot.cs @@ -1,10 +1,10 @@ -// +// using System; using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Migrations { @@ -16,18 +16,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("customer_management") - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) + .HasAnnotation("ProductVersion", "3.1.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerFlagsEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("IsBlocked") - .HasColumnName("is_blocked"); + .HasColumnName("is_blocked") + .HasColumnType("boolean"); b.HasKey("CustomerId"); @@ -37,12 +38,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.CustomerRegistrationReferralDataEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("ReferralCode") .IsRequired() - .HasColumnName("referral_code"); + .HasColumnName("referral_code") + .HasColumnType("text"); b.HasKey("CustomerId"); @@ -52,18 +54,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.EmailVerificationCodeEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("ExpireDate") - .HasColumnName("expire_date"); + .HasColumnName("expire_date") + .HasColumnType("timestamp without time zone"); b.Property("IsVerified") - .HasColumnName("is_verified"); + .HasColumnName("is_verified") + .HasColumnType("boolean"); b.Property("VerificationCode") .IsRequired() - .HasColumnName("code"); + .HasColumnName("code") + .HasColumnType("text"); b.HasKey("CustomerId"); @@ -76,15 +81,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("MAVN.Service.CustomerManagement.MsSqlRepositories.Entities.PhoneVerificationCodeEntity", b => { b.Property("CustomerId") - .ValueGeneratedOnAdd() - .HasColumnName("customer_id"); + .HasColumnName("customer_id") + .HasColumnType("text"); b.Property("ExpireDate") - .HasColumnName("expire_date"); + .HasColumnName("expire_date") + .HasColumnType("timestamp without time zone"); b.Property("VerificationCode") .IsRequired() - .HasColumnName("code"); + .HasColumnName("code") + .HasColumnType("text"); b.HasKey("CustomerId"); diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomerFlagsRepository.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomerFlagsRepository.cs index 03fb19a..85b4096 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomerFlagsRepository.cs +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomerFlagsRepository.cs @@ -1,22 +1,23 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Threading.Tasks; -using MAVN.Common.MsSql; +using MAVN.Persistence.PostgreSQL.Legacy; using MAVN.Service.CustomerManagement.Domain.Models; using MAVN.Service.CustomerManagement.Domain.Repositories; using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; using MAVN.Service.CustomerManagement.MsSqlRepositories.Entities; using Microsoft.EntityFrameworkCore; +using Npgsql; namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Repositories { public class CustomerFlagsRepository : ICustomerFlagsRepository { - private readonly MsSqlContextFactory _contextFactory; + private readonly PostgreSQLContextFactory _contextFactory; public CustomerFlagsRepository( - MsSqlContextFactory contextFactory) + PostgreSQLContextFactory contextFactory) { _contextFactory = contextFactory; } @@ -35,8 +36,8 @@ public async Task CreateOrUpdateAsync(string customerId, bool is } catch (DbUpdateException e) { - if (e.InnerException is SqlException sqlException && - sqlException.Number == MsSqlErrorCodes.PrimaryKeyConstraintViolation) + if (e.InnerException is PostgresException sqlException && + sqlException.SqlState == PostgresErrorCodes.UniqueViolation) { context.CustomerFlags.Update(entity); diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomersRegistrationReferralDataRepository.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomersRegistrationReferralDataRepository.cs index 6eeaaba..a89702d 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomersRegistrationReferralDataRepository.cs +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/CustomersRegistrationReferralDataRepository.cs @@ -1,23 +1,24 @@ -using System.Data.SqlClient; +using System.Data.SqlClient; using System.Threading.Tasks; using Common.Log; using Lykke.Common.Log; -using MAVN.Common.MsSql; +using MAVN.Persistence.PostgreSQL.Legacy; using MAVN.Service.CustomerManagement.Domain.Models; using MAVN.Service.CustomerManagement.Domain.Repositories; using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; using MAVN.Service.CustomerManagement.MsSqlRepositories.Entities; using Microsoft.EntityFrameworkCore; +using Npgsql; namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Repositories { public class CustomersRegistrationReferralDataRepository : ICustomersRegistrationReferralDataRepository { - private readonly MsSqlContextFactory _contextFactory; + private readonly PostgreSQLContextFactory _contextFactory; private readonly ILog _log; public CustomersRegistrationReferralDataRepository( - MsSqlContextFactory contextFactory, + PostgreSQLContextFactory contextFactory, ILogFactory logFactory) { _contextFactory = contextFactory; @@ -38,8 +39,8 @@ public async Task AddAsync(string customerId, string referralCode) } catch (DbUpdateException e) { - if (e.InnerException is SqlException sqlException - && sqlException.Number == MsSqlErrorCodes.PrimaryKeyConstraintViolation) + if (e.InnerException is PostgresException sqlException + && sqlException.SqlState == PostgresErrorCodes.UniqueViolation) { _log.Error(e, "Error on customer referral data context saving"); } diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/EmailVerificationCodeRepository.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/EmailVerificationCodeRepository.cs index ac0dc36..cccea8c 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/EmailVerificationCodeRepository.cs +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/EmailVerificationCodeRepository.cs @@ -1,21 +1,22 @@ -using System; +using System; using System.Data.SqlClient; using System.Threading.Tasks; -using MAVN.Common.MsSql; +using MAVN.Persistence.PostgreSQL.Legacy; using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; using MAVN.Service.CustomerManagement.MsSqlRepositories.Entities; using MAVN.Service.CustomerManagement.Domain.Models; using MAVN.Service.CustomerManagement.Domain.Repositories; using Microsoft.EntityFrameworkCore; +using Npgsql; namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Repositories { public class EmailVerificationCodeRepository : IEmailVerificationCodeRepository { - private readonly MsSqlContextFactory _contextFactory; + private readonly PostgreSQLContextFactory _contextFactory; private readonly TimeSpan _verificationEmailExpirePeriod; - public EmailVerificationCodeRepository(MsSqlContextFactory contextFactory, TimeSpan verificationEmailExpirePeriod) + public EmailVerificationCodeRepository(PostgreSQLContextFactory contextFactory, TimeSpan verificationEmailExpirePeriod) { _contextFactory = contextFactory; _verificationEmailExpirePeriod = verificationEmailExpirePeriod; @@ -36,8 +37,8 @@ public async Task CreateOrUpdateAsync(string customerId, stri } catch (DbUpdateException e) { - if (e.InnerException is SqlException sqlException && - sqlException.Number == MsSqlErrorCodes.PrimaryKeyConstraintViolation) + if (e.InnerException is PostgresException sqlException && + sqlException.SqlState == PostgresErrorCodes.UniqueViolation) { context.EmailVerificationCodes.Update(entity); diff --git a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/PhoneVerificationCodeRepository.cs b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/PhoneVerificationCodeRepository.cs index 5be1637..95d1c0b 100644 --- a/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/PhoneVerificationCodeRepository.cs +++ b/src/MAVN.Service.CustomerManagement.MsSqlRepositories/Repositories/PhoneVerificationCodeRepository.cs @@ -1,20 +1,21 @@ -using System; +using System; using System.Data.SqlClient; using System.Threading.Tasks; -using MAVN.Common.MsSql; +using MAVN.Persistence.PostgreSQL.Legacy; using MAVN.Service.CustomerManagement.Domain.Models; using MAVN.Service.CustomerManagement.Domain.Repositories; using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; using MAVN.Service.CustomerManagement.MsSqlRepositories.Entities; using Microsoft.EntityFrameworkCore; +using Npgsql; namespace MAVN.Service.CustomerManagement.MsSqlRepositories.Repositories { public class PhoneVerificationCodeRepository : IPhoneVerificationCodeRepository { - private readonly MsSqlContextFactory _contextFactory; + private readonly PostgreSQLContextFactory _contextFactory; - public PhoneVerificationCodeRepository(MsSqlContextFactory contextFactory) + public PhoneVerificationCodeRepository(PostgreSQLContextFactory contextFactory) { _contextFactory = contextFactory; } @@ -34,8 +35,8 @@ public async Task CreateOrUpdateAsync(string customerId, } catch (DbUpdateException e) { - if (e.InnerException is SqlException sqlException && - sqlException.Number == MsSqlErrorCodes.PrimaryKeyConstraintViolation) + if (e.InnerException is PostgresException sqlException && + sqlException.SqlState == PostgresErrorCodes.UniqueViolation) { context.PhoneVerificationCodes.Update(entity); diff --git a/src/MAVN.Service.CustomerManagement/Dockerfile b/src/MAVN.Service.CustomerManagement/Dockerfile index f068834..9e3e2a8 100644 --- a/src/MAVN.Service.CustomerManagement/Dockerfile +++ b/src/MAVN.Service.CustomerManagement/Dockerfile @@ -1,4 +1,4 @@ -FROM microsoft/dotnet:2.2-aspnetcore-runtime +FROM microsoft/dotnet:3.1-aspnetcore-runtime WORKDIR /app COPY . . ENTRYPOINT ["dotnet", "MAVN.Service.CustomerManagement.dll"] diff --git a/src/MAVN.Service.CustomerManagement/MAVN.Service.CustomerManagement.csproj b/src/MAVN.Service.CustomerManagement/MAVN.Service.CustomerManagement.csproj index 371330c..69bbf32 100644 --- a/src/MAVN.Service.CustomerManagement/MAVN.Service.CustomerManagement.csproj +++ b/src/MAVN.Service.CustomerManagement/MAVN.Service.CustomerManagement.csproj @@ -1,6 +1,6 @@ - netcoreapp2.2 + netcoreapp3.1 Exe 1.0.0 @@ -15,6 +15,9 @@ $(OutputPath)$(AssemblyName).xml + + Always + PreserveNewest @@ -22,8 +25,9 @@ - - + + + diff --git a/src/MAVN.Service.CustomerManagement/Modules/DataModule.cs b/src/MAVN.Service.CustomerManagement/Modules/DataModule.cs index 521775e..2875496 100644 --- a/src/MAVN.Service.CustomerManagement/Modules/DataModule.cs +++ b/src/MAVN.Service.CustomerManagement/Modules/DataModule.cs @@ -1,11 +1,11 @@ -using Autofac; +using Autofac; using JetBrains.Annotations; -using MAVN.Common.MsSql; using MAVN.Service.CustomerManagement.MsSqlRepositories.Contexts; using MAVN.Service.CustomerManagement.MsSqlRepositories.Repositories; using MAVN.Service.CustomerManagement.Domain.Repositories; using MAVN.Service.CustomerManagement.Settings; using Lykke.SettingsReader; +using MAVN.Persistence.PostgreSQL.Legacy; namespace MAVN.Service.CustomerManagement.Modules { @@ -21,7 +21,7 @@ public DataModule(IReloadingManager appSettings) protected override void Load(ContainerBuilder builder) { - builder.RegisterMsSql( + builder.RegisterPostgreSQL( _settings.Db.DataConnString, connString => new CmContext(connString, false), dbConn => new CmContext(dbConn)); diff --git a/tests/MAVN.Service.CustomerManagement.Tests/MAVN.Service.CustomerManagement.Tests.csproj b/tests/MAVN.Service.CustomerManagement.Tests/MAVN.Service.CustomerManagement.Tests.csproj index c6ab7b0..77636ca 100644 --- a/tests/MAVN.Service.CustomerManagement.Tests/MAVN.Service.CustomerManagement.Tests.csproj +++ b/tests/MAVN.Service.CustomerManagement.Tests/MAVN.Service.CustomerManagement.Tests.csproj @@ -1,19 +1,19 @@ - + - netcoreapp2.2 + netcoreapp3.1 1.0.0 - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + - - + + - + all runtime; build; native; contentfiles; analyzers