From e6d4300faeac2b40aacd0622e50148675f35d544 Mon Sep 17 00:00:00 2001 From: Iliyan Iliev Date: Thu, 2 Jul 2020 10:27:51 +0300 Subject: [PATCH] Closes #9 --- ...Service.EncryptedFileStorage.Client.csproj | 4 +- ...ryptedFileStorage.AzureRepositories.csproj | 14 ++--- ...Service.EncryptedFileStorage.Domain.csproj | 6 +- ...EncryptedFileStorage.DomainServices.csproj | 14 ++--- .../DatabaseContext.cs | 8 +-- .../EncryptedFileConfiguration.cs | 4 +- ...ryptedFileStorage.MsSqlRepositories.csproj | 12 ++-- ...2144121_AddEncryptedFileEntity.Designer.cs | 57 ----------------- ...117_UpdatedEncryptedFileEntity.Designer.cs | 56 ----------------- ...191004142117_UpdatedEncryptedFileEntity.cs | 63 ------------------- ...CompletedToEncryptedFileEntity.Designer.cs | 60 ------------------ ...dIsUploadCompletedToEncryptedFileEntity.cs | 25 -------- ...191007124953_ReducedOriginSize.Designer.cs | 60 ------------------ .../20191007124953_ReducedOriginSize.cs | 31 --------- .../20191009085128_UpdatedBlobNameSize.cs | 33 ---------- ....cs => 20200702072646_Initial.Designer.cs} | 26 +++++--- ...ileEntity.cs => 20200702072646_Initial.cs} | 15 ++--- .../DatabaseContextModelSnapshot.cs | 22 ++++--- .../EncryptedFileInfoRepository.cs | 8 +-- .../Dockerfile | 2 +- .../MAVN.Service.EncryptedFileStorage.csproj | 12 ++-- .../Modules/ServiceModule.cs | 6 +- ....Service.EncryptedFileStorage.Tests.csproj | 12 ++-- 23 files changed, 93 insertions(+), 457 deletions(-) delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191002144121_AddEncryptedFileEntity.Designer.cs delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.Designer.cs delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.cs delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.Designer.cs delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.cs delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.Designer.cs delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.cs delete mode 100644 src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191009085128_UpdatedBlobNameSize.cs rename src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/{20191009085128_UpdatedBlobNameSize.Designer.cs => 20200702072646_Initial.Designer.cs} (66%) rename src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/{20191002144121_AddEncryptedFileEntity.cs => 20200702072646_Initial.cs} (74%) diff --git a/client/MAVN.Service.EncryptedFileStorage.Client/MAVN.Service.EncryptedFileStorage.Client.csproj b/client/MAVN.Service.EncryptedFileStorage.Client/MAVN.Service.EncryptedFileStorage.Client.csproj index cd14b8e..c4f5f56 100644 --- a/client/MAVN.Service.EncryptedFileStorage.Client/MAVN.Service.EncryptedFileStorage.Client.csproj +++ b/client/MAVN.Service.EncryptedFileStorage.Client/MAVN.Service.EncryptedFileStorage.Client.csproj @@ -14,8 +14,8 @@ - - + + \ No newline at end of file diff --git a/src/MAVN.Service.EncryptedFileStorage.AzureRepositories/MAVN.Service.EncryptedFileStorage.AzureRepositories.csproj b/src/MAVN.Service.EncryptedFileStorage.AzureRepositories/MAVN.Service.EncryptedFileStorage.AzureRepositories.csproj index ba8004d..b466a2d 100644 --- a/src/MAVN.Service.EncryptedFileStorage.AzureRepositories/MAVN.Service.EncryptedFileStorage.AzureRepositories.csproj +++ b/src/MAVN.Service.EncryptedFileStorage.AzureRepositories/MAVN.Service.EncryptedFileStorage.AzureRepositories.csproj @@ -1,17 +1,17 @@ - netcoreapp2.2 + netcoreapp3.1 1.0.0 - - - - - - + + + + + + diff --git a/src/MAVN.Service.EncryptedFileStorage.Domain/MAVN.Service.EncryptedFileStorage.Domain.csproj b/src/MAVN.Service.EncryptedFileStorage.Domain/MAVN.Service.EncryptedFileStorage.Domain.csproj index 0a34cec..6e4e1ef 100644 --- a/src/MAVN.Service.EncryptedFileStorage.Domain/MAVN.Service.EncryptedFileStorage.Domain.csproj +++ b/src/MAVN.Service.EncryptedFileStorage.Domain/MAVN.Service.EncryptedFileStorage.Domain.csproj @@ -1,10 +1,10 @@ - netcoreapp2.2 + netcoreapp3.1 1.0.0 - - + + diff --git a/src/MAVN.Service.EncryptedFileStorage.DomainServices/MAVN.Service.EncryptedFileStorage.DomainServices.csproj b/src/MAVN.Service.EncryptedFileStorage.DomainServices/MAVN.Service.EncryptedFileStorage.DomainServices.csproj index 725bf46..e1badd3 100644 --- a/src/MAVN.Service.EncryptedFileStorage.DomainServices/MAVN.Service.EncryptedFileStorage.DomainServices.csproj +++ b/src/MAVN.Service.EncryptedFileStorage.DomainServices/MAVN.Service.EncryptedFileStorage.DomainServices.csproj @@ -1,17 +1,17 @@ - netcoreapp2.2 + netcoreapp3.1 1.0.0 - - - - - - + + + + + + diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/DatabaseContext.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/DatabaseContext.cs index b09ed4a..29d7619 100644 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/DatabaseContext.cs +++ b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/DatabaseContext.cs @@ -1,13 +1,13 @@ -using System.Data.Common; +using System.Data.Common; using JetBrains.Annotations; -using MAVN.Common.MsSql; +using MAVN.Persistence.PostgreSQL.Legacy; using MAVN.Service.EncryptedFileStorage.Domain.Models; using MAVN.Service.EncryptedFileStorage.MsSqlRepositories.EntityConfigurations; using Microsoft.EntityFrameworkCore; namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories { - public class DatabaseContext : MsSqlContext + public class DatabaseContext : PostgreSQLContext { private const string Schema = "encrypted_files_storage"; @@ -42,7 +42,7 @@ public DatabaseContext(DbConnection dbConnection, bool isForMocks = false, { } - protected override void OnLykkeModelCreating(ModelBuilder modelBuilder) + protected override void OnMAVNModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration(new EncryptedFileConfiguration()); } diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/EntityConfigurations/EncryptedFileConfiguration.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/EntityConfigurations/EncryptedFileConfiguration.cs index 3364e82..814a418 100644 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/EntityConfigurations/EncryptedFileConfiguration.cs +++ b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/EntityConfigurations/EncryptedFileConfiguration.cs @@ -1,4 +1,4 @@ -using MAVN.Service.EncryptedFileStorage.Domain.Models; +using MAVN.Service.EncryptedFileStorage.Domain.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -12,7 +12,7 @@ public void Configure(EntityTypeBuilder builder) builder.HasKey(x => x.FileId); - builder.Property(x => x.FileId).ValueGeneratedOnAdd().HasDefaultValueSql("newid()"); + builder.Property(x => x.FileId).ValueGeneratedOnAdd(); builder.Property(x => x.Origin).IsRequired().HasMaxLength(63); builder.Property(x => x.FileName).IsRequired().HasMaxLength(255); builder.Property(x => x.BlobName).HasMaxLength(1024); diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/MAVN.Service.EncryptedFileStorage.MsSqlRepositories.csproj b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/MAVN.Service.EncryptedFileStorage.MsSqlRepositories.csproj index ec86f6d..04d8728 100644 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/MAVN.Service.EncryptedFileStorage.MsSqlRepositories.csproj +++ b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/MAVN.Service.EncryptedFileStorage.MsSqlRepositories.csproj @@ -1,16 +1,20 @@ - + - netcoreapp2.2 + netcoreapp3.1 1.0.0 - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191002144121_AddEncryptedFileEntity.Designer.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191002144121_AddEncryptedFileEntity.Designer.cs deleted file mode 100644 index 21b70dc..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191002144121_AddEncryptedFileEntity.Designer.cs +++ /dev/null @@ -1,57 +0,0 @@ -// -using System; -using MAVN.Service.EncryptedFileStorage.MsSqlRepositories; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - [DbContext(typeof(DatabaseContext))] - [Migration("20191002144121_AddEncryptedFileEntity")] - partial class AddEncryptedFileEntity - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("encrypted_files_storage") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.EncryptedFileStorage.Domain.Models.EncryptedFile", b => - { - b.Property("FileId") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("newid()"); - - b.Property("BlobName") - .IsRequired() - .HasMaxLength(255); - - b.Property("FileDate"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(255); - - b.Property("Length"); - - b.Property("Origin") - .IsRequired() - .HasMaxLength(200); - - b.HasKey("FileId"); - - b.HasIndex("Origin", "FileName") - .IsUnique(); - - b.ToTable("encrypted_files"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.Designer.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.Designer.cs deleted file mode 100644 index 86442c8..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.Designer.cs +++ /dev/null @@ -1,56 +0,0 @@ -// -using System; -using MAVN.Service.EncryptedFileStorage.MsSqlRepositories; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - [DbContext(typeof(DatabaseContext))] - [Migration("20191004142117_UpdatedEncryptedFileEntity")] - partial class UpdatedEncryptedFileEntity - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("encrypted_files_storage") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.EncryptedFileStorage.Domain.Models.EncryptedFile", b => - { - b.Property("FileId") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("newid()"); - - b.Property("BlobName") - .HasMaxLength(255); - - b.Property("FileDate"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(255); - - b.Property("Length"); - - b.Property("Origin") - .IsRequired() - .HasMaxLength(200); - - b.HasKey("FileId"); - - b.HasIndex("Origin", "FileName") - .IsUnique(); - - b.ToTable("encrypted_files"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.cs deleted file mode 100644 index 8a97cea..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142117_UpdatedEncryptedFileEntity.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - public partial class UpdatedEncryptedFileEntity : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Length", - schema: "encrypted_files_storage", - table: "encrypted_files", - nullable: true, - oldClrType: typeof(long)); - - migrationBuilder.AlterColumn( - name: "FileDate", - schema: "encrypted_files_storage", - table: "encrypted_files", - nullable: true, - oldClrType: typeof(DateTime)); - - migrationBuilder.AlterColumn( - name: "BlobName", - schema: "encrypted_files_storage", - table: "encrypted_files", - maxLength: 255, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 255); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Length", - schema: "encrypted_files_storage", - table: "encrypted_files", - nullable: false, - oldClrType: typeof(long), - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "FileDate", - schema: "encrypted_files_storage", - table: "encrypted_files", - nullable: false, - oldClrType: typeof(DateTime), - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "BlobName", - schema: "encrypted_files_storage", - table: "encrypted_files", - maxLength: 255, - nullable: false, - oldClrType: typeof(string), - oldMaxLength: 255, - oldNullable: true); - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.Designer.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.Designer.cs deleted file mode 100644 index 7dcbdda..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.Designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; -using MAVN.Service.EncryptedFileStorage.MsSqlRepositories; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - [DbContext(typeof(DatabaseContext))] - [Migration("20191004142649_AddedIsUploadCompletedToEncryptedFileEntity")] - partial class AddedIsUploadCompletedToEncryptedFileEntity - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("encrypted_files_storage") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.EncryptedFileStorage.Domain.Models.EncryptedFile", b => - { - b.Property("FileId") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("newid()"); - - b.Property("BlobName") - .HasMaxLength(255); - - b.Property("FileDate"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(255); - - b.Property("IsUploadCompleted") - .ValueGeneratedOnAdd() - .HasDefaultValue(false); - - b.Property("Length"); - - b.Property("Origin") - .IsRequired() - .HasMaxLength(200); - - b.HasKey("FileId"); - - b.HasIndex("Origin", "FileName") - .IsUnique(); - - b.ToTable("encrypted_files"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.cs deleted file mode 100644 index 0ce4855..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191004142649_AddedIsUploadCompletedToEncryptedFileEntity.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - public partial class AddedIsUploadCompletedToEncryptedFileEntity : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsUploadCompleted", - schema: "encrypted_files_storage", - table: "encrypted_files", - nullable: false, - defaultValue: false); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsUploadCompleted", - schema: "encrypted_files_storage", - table: "encrypted_files"); - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.Designer.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.Designer.cs deleted file mode 100644 index 1e34c61..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.Designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; -using MAVN.Service.EncryptedFileStorage.MsSqlRepositories; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - [DbContext(typeof(DatabaseContext))] - [Migration("20191007124953_ReducedOriginSize")] - partial class ReducedOriginSize - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("encrypted_files_storage") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("MAVN.Service.EncryptedFileStorage.Domain.Models.EncryptedFile", b => - { - b.Property("FileId") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("newid()"); - - b.Property("BlobName") - .HasMaxLength(255); - - b.Property("FileDate"); - - b.Property("FileName") - .IsRequired() - .HasMaxLength(255); - - b.Property("IsUploadCompleted") - .ValueGeneratedOnAdd() - .HasDefaultValue(false); - - b.Property("Length"); - - b.Property("Origin") - .IsRequired() - .HasMaxLength(63); - - b.HasKey("FileId"); - - b.HasIndex("Origin", "FileName") - .IsUnique(); - - b.ToTable("encrypted_files"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.cs deleted file mode 100644 index b210bc1..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191007124953_ReducedOriginSize.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - public partial class ReducedOriginSize : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Origin", - schema: "encrypted_files_storage", - table: "encrypted_files", - maxLength: 63, - nullable: false, - oldClrType: typeof(string), - oldMaxLength: 200); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Origin", - schema: "encrypted_files_storage", - table: "encrypted_files", - maxLength: 200, - nullable: false, - oldClrType: typeof(string), - oldMaxLength: 63); - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191009085128_UpdatedBlobNameSize.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191009085128_UpdatedBlobNameSize.cs deleted file mode 100644 index cb283df..0000000 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191009085128_UpdatedBlobNameSize.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations -{ - public partial class UpdatedBlobNameSize : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "BlobName", - schema: "encrypted_files_storage", - table: "encrypted_files", - maxLength: 1024, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 255, - oldNullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "BlobName", - schema: "encrypted_files_storage", - table: "encrypted_files", - maxLength: 255, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 1024, - oldNullable: true); - } - } -} diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191009085128_UpdatedBlobNameSize.Designer.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20200702072646_Initial.Designer.cs similarity index 66% rename from src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191009085128_UpdatedBlobNameSize.Designer.cs rename to src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20200702072646_Initial.Designer.cs index e977190..304add4 100644 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191009085128_UpdatedBlobNameSize.Designer.cs +++ b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20200702072646_Initial.Designer.cs @@ -1,50 +1,56 @@ -// +// using System; using MAVN.Service.EncryptedFileStorage.MsSqlRepositories; 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.EncryptedFileStorage.MsSqlRepositories.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20191009085128_UpdatedBlobNameSize")] - partial class UpdatedBlobNameSize + [Migration("20200702072646_Initial")] + partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("encrypted_files_storage") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .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.EncryptedFileStorage.Domain.Models.EncryptedFile", b => { b.Property("FileId") .ValueGeneratedOnAdd() - .HasDefaultValueSql("newid()"); + .HasColumnType("uuid"); b.Property("BlobName") + .HasColumnType("character varying(1024)") .HasMaxLength(1024); - b.Property("FileDate"); + b.Property("FileDate") + .HasColumnType("timestamp without time zone"); b.Property("FileName") .IsRequired() + .HasColumnType("character varying(255)") .HasMaxLength(255); b.Property("IsUploadCompleted") .ValueGeneratedOnAdd() + .HasColumnType("boolean") .HasDefaultValue(false); - b.Property("Length"); + b.Property("Length") + .HasColumnType("bigint"); b.Property("Origin") .IsRequired() + .HasColumnType("character varying(63)") .HasMaxLength(63); b.HasKey("FileId"); diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191002144121_AddEncryptedFileEntity.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20200702072646_Initial.cs similarity index 74% rename from src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191002144121_AddEncryptedFileEntity.cs rename to src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20200702072646_Initial.cs index 60c3e8f..8a454cf 100644 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20191002144121_AddEncryptedFileEntity.cs +++ b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/20200702072646_Initial.cs @@ -1,9 +1,9 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations { - public partial class AddEncryptedFileEntity : Migration + public partial class Initial : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -15,12 +15,13 @@ protected override void Up(MigrationBuilder migrationBuilder) schema: "encrypted_files_storage", columns: table => new { - FileId = table.Column(nullable: false, defaultValueSql: "newid()"), - Origin = table.Column(maxLength: 200, nullable: false), + FileId = table.Column(nullable: false), + Origin = table.Column(maxLength: 63, nullable: false), FileName = table.Column(maxLength: 255, nullable: false), - BlobName = table.Column(maxLength: 255, nullable: false), - Length = table.Column(nullable: false), - FileDate = table.Column(nullable: false) + BlobName = table.Column(maxLength: 1024, nullable: true), + Length = table.Column(nullable: true), + FileDate = table.Column(nullable: true), + IsUploadCompleted = table.Column(nullable: false, defaultValue: false) }, constraints: table => { diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/DatabaseContextModelSnapshot.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/DatabaseContextModelSnapshot.cs index fb1cdc3..5b9e0e0 100644 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/DatabaseContextModelSnapshot.cs +++ b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Migrations/DatabaseContextModelSnapshot.cs @@ -1,10 +1,10 @@ -// +// using System; using MAVN.Service.EncryptedFileStorage.MsSqlRepositories; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Migrations { @@ -16,33 +16,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder .HasDefaultSchema("encrypted_files_storage") - .HasAnnotation("ProductVersion", "2.2.4-servicing-10062") - .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.EncryptedFileStorage.Domain.Models.EncryptedFile", b => { b.Property("FileId") .ValueGeneratedOnAdd() - .HasDefaultValueSql("newid()"); + .HasColumnType("uuid"); b.Property("BlobName") + .HasColumnType("character varying(1024)") .HasMaxLength(1024); - b.Property("FileDate"); + b.Property("FileDate") + .HasColumnType("timestamp without time zone"); b.Property("FileName") .IsRequired() + .HasColumnType("character varying(255)") .HasMaxLength(255); b.Property("IsUploadCompleted") .ValueGeneratedOnAdd() + .HasColumnType("boolean") .HasDefaultValue(false); - b.Property("Length"); + b.Property("Length") + .HasColumnType("bigint"); b.Property("Origin") .IsRequired() + .HasColumnType("character varying(63)") .HasMaxLength(63); b.HasKey("FileId"); diff --git a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Repositories/EncryptedFileInfoRepository.cs b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Repositories/EncryptedFileInfoRepository.cs index db339d7..810778d 100644 --- a/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Repositories/EncryptedFileInfoRepository.cs +++ b/src/MAVN.Service.EncryptedFileStorage.MsSqlRepositories/Repositories/EncryptedFileInfoRepository.cs @@ -1,8 +1,8 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using MAVN.Common.MsSql; +using MAVN.Persistence.PostgreSQL.Legacy; using MAVN.Service.EncryptedFileStorage.Domain.Models; using MAVN.Service.EncryptedFileStorage.Domain.Repositories; using Microsoft.EntityFrameworkCore; @@ -11,9 +11,9 @@ namespace MAVN.Service.EncryptedFileStorage.MsSqlRepositories.Repositories { public class EncryptedFileInfoRepository : IEncryptedFileInfoRepository { - private readonly MsSqlContextFactory _contextFactory; + private readonly PostgreSQLContextFactory _contextFactory; - public EncryptedFileInfoRepository(MsSqlContextFactory contextFactory) + public EncryptedFileInfoRepository(PostgreSQLContextFactory contextFactory) { _contextFactory = contextFactory; } diff --git a/src/MAVN.Service.EncryptedFileStorage/Dockerfile b/src/MAVN.Service.EncryptedFileStorage/Dockerfile index f951a95..70e4343 100644 --- a/src/MAVN.Service.EncryptedFileStorage/Dockerfile +++ b/src/MAVN.Service.EncryptedFileStorage/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.EncryptedFileStorage.dll"] diff --git a/src/MAVN.Service.EncryptedFileStorage/MAVN.Service.EncryptedFileStorage.csproj b/src/MAVN.Service.EncryptedFileStorage/MAVN.Service.EncryptedFileStorage.csproj index d718caa..cb54b21 100644 --- a/src/MAVN.Service.EncryptedFileStorage/MAVN.Service.EncryptedFileStorage.csproj +++ b/src/MAVN.Service.EncryptedFileStorage/MAVN.Service.EncryptedFileStorage.csproj @@ -1,6 +1,6 @@ - + - netcoreapp2.2 + netcoreapp3.1 Exe 1.0.0 @@ -13,6 +13,9 @@ latest + + Always + PreserveNewest @@ -20,8 +23,9 @@ - - + + + diff --git a/src/MAVN.Service.EncryptedFileStorage/Modules/ServiceModule.cs b/src/MAVN.Service.EncryptedFileStorage/Modules/ServiceModule.cs index e5f42aa..26d08f5 100644 --- a/src/MAVN.Service.EncryptedFileStorage/Modules/ServiceModule.cs +++ b/src/MAVN.Service.EncryptedFileStorage/Modules/ServiceModule.cs @@ -1,9 +1,8 @@ -using System; +using System; using Autofac; using AzureStorage; using AzureStorage.Blob; using JetBrains.Annotations; -using MAVN.Common.MsSql; using MAVN.Service.EncryptedFileStorage.Auth; using MAVN.Service.EncryptedFileStorage.AzureRepositories; using MAVN.Service.EncryptedFileStorage.Client; @@ -15,6 +14,7 @@ using MAVN.Service.EncryptedFileStorage.Services; using MAVN.Service.EncryptedFileStorage.Settings; using Lykke.SettingsReader; +using MAVN.Persistence.PostgreSQL.Legacy; using Microsoft.Azure.KeyVault; using Microsoft.Azure.Services.AppAuthentication; using Microsoft.Azure.Storage; @@ -79,7 +79,7 @@ protected override void Load(ContainerBuilder builder) .SingleInstance(); //Repositories - builder.RegisterMsSql( + builder.RegisterPostgreSQL( _appSettings.CurrentValue.EncryptedFileStorageService.Db.DataConnString, connString => new DatabaseContext(connString, false), dbConn => new DatabaseContext(dbConn)); diff --git a/tests/MAVN.Service.EncryptedFileStorage.Tests/MAVN.Service.EncryptedFileStorage.Tests.csproj b/tests/MAVN.Service.EncryptedFileStorage.Tests/MAVN.Service.EncryptedFileStorage.Tests.csproj index 8bb33b4..eb85c79 100644 --- a/tests/MAVN.Service.EncryptedFileStorage.Tests/MAVN.Service.EncryptedFileStorage.Tests.csproj +++ b/tests/MAVN.Service.EncryptedFileStorage.Tests/MAVN.Service.EncryptedFileStorage.Tests.csproj @@ -1,18 +1,18 @@ - netcoreapp2.2 + netcoreapp3.1 1.0.0 - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive