changing database to postgres
CodeQL / Analyze (csharp) (push) Has been cancelled
DevSkim / DevSkim (push) Has been cancelled
Build / build-and-test-macOS-latest (push) Has been cancelled
Build / build-and-test-ubuntu-latest (push) Has been cancelled
Build / build-and-test-windows-latest (push) Has been cancelled
SonarCloud / Build and Analyze (push) Has been cancelled

This commit is contained in:
2025-09-24 19:12:58 +03:30
parent d9511f29c7
commit 6d28773c06
23 changed files with 180 additions and 360 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
MSSQL_SA_PASSWORD=YOUR_STRONG_!Passw0rd MSSQL_SA_PASSWORD=Programmer.369
MSSQL_PORT=1433 MSSQL_PORT=1433
REDIS_PASSWORD=YOUR_STRONG_!Passw0rd REDIS_PASSWORD=Programmer.369
REDIS_PORT=6379 REDIS_PORT=6379
MONGO_PORT=27017 MONGO_PORT=27017
ASPNETCORE_ENVIRONMENT=Development ASPNETCORE_ENVIRONMENT=Development
+1
View File
@@ -55,6 +55,7 @@
<PackageVersion Include="MiniProfiler.EntityFrameworkCore" Version="4.5.*" /> <PackageVersion Include="MiniProfiler.EntityFrameworkCore" Version="4.5.*" />
<PackageVersion Include="MongoDB.Bson" Version="3.5.*" /> <PackageVersion Include="MongoDB.Bson" Version="3.5.*" />
<PackageVersion Include="MongoDB.Driver" Version="3.5.*" /> <PackageVersion Include="MongoDB.Driver" Version="3.5.*" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.*" /> <PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.*" />
<PackageVersion Include="NSubstitute" Version="5.3.*" /> <PackageVersion Include="NSubstitute" Version="5.3.*" />
<PackageVersion Include="Polly" Version="8.6.*" /> <PackageVersion Include="Polly" Version="8.6.*" />
@@ -8,8 +8,11 @@ public sealed class ConnectionOptions : IAppOptions
{ {
static string IAppOptions.ConfigSectionPath => "ConnectionStrings"; static string IAppOptions.ConfigSectionPath => "ConnectionStrings";
// [Required]
// public string SqlConnection { get; private init; }
[Required] [Required]
public string SqlConnection { get; private init; } public string PostgresConnection { get; private init; }
[Required] [Required]
public string NoSqlConnection { get; private init; } public string NoSqlConnection { get; private init; }
@@ -7,7 +7,7 @@ namespace Shop.Infrastructure.Data.Context;
public abstract class BaseDbContext<TContext>(DbContextOptions<TContext> dbOptions) : DbContext(dbOptions) public abstract class BaseDbContext<TContext>(DbContextOptions<TContext> dbOptions) : DbContext(dbOptions)
where TContext : DbContext where TContext : DbContext
{ {
private const string Collation = "Latin1_General_CI_AI"; //private const string Collation = "en_US.UTF-8";
public override ChangeTracker ChangeTracker public override ChangeTracker ChangeTracker
{ {
@@ -33,7 +33,7 @@ public abstract class BaseDbContext<TContext>(DbContextOptions<TContext> dbOptio
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)
{ {
modelBuilder modelBuilder
.UseCollation(Collation) // .UseCollation(Collation)
.RemoveCascadeDeleteConvention(); .RemoveCascadeDeleteConvention();
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
@@ -26,5 +26,8 @@ internal static class EntityTypeBuilderExtensions
// Ignores the DomainEvents property for the entity. // Ignores the DomainEvents property for the entity.
builder builder
.Ignore(entity => entity.DomainEvents); .Ignore(entity => entity.DomainEvents);
} }
} }
@@ -1,5 +1,7 @@
using System;
using System.Linq; using System.Linq;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Shop.Infrastructure.Data.Extensions; namespace Shop.Infrastructure.Data.Extensions;
@@ -21,5 +23,27 @@ internal static class ModelBuilderExtensions
// Change the delete behavior of each foreign key to restrict // Change the delete behavior of each foreign key to restrict
foreach (var fk in foreignKeys) foreach (var fk in foreignKeys)
fk.DeleteBehavior = DeleteBehavior.Restrict; fk.DeleteBehavior = DeleteBehavior.Restrict;
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
foreach (var property in entityType.GetProperties())
{
if (property.ClrType == typeof(DateTime))
{
property.SetValueConverter(new ValueConverter<DateTime, DateTime>(
v => v.Kind == DateTimeKind.Utc ? v : v.ToUniversalTime(),
v => DateTime.SpecifyKind(v, DateTimeKind.Utc)
));
}
else if (property.ClrType == typeof(DateTime?))
{
property.SetValueConverter(new ValueConverter<DateTime?, DateTime?>(
v => v.HasValue ? (v.Value.Kind == DateTimeKind.Utc ? v : v.Value.ToUniversalTime()) : v,
v => v.HasValue ? DateTime.SpecifyKind(v.Value, DateTimeKind.Utc) : v
));
}
}
}
} }
} }
+8 -3
View File
@@ -33,10 +33,13 @@ internal sealed class UnitOfWork(
logger.LogInformation("----- Begin transaction: '{TransactionId}'", transaction.TransactionId); logger.LogInformation("----- Begin transaction: '{TransactionId}'", transaction.TransactionId);
IReadOnlyList<BaseEvent> domainEvents = Array.Empty<BaseEvent>();
IReadOnlyList<EventStore> eventStores = Array.Empty<EventStore>();
try try
{ {
// Getting the domain events and event stores from the tracked entities in the EF Core context. // Getting the domain events and event stores from the tracked entities in the EF Core context.
var (domainEvents, eventStores) = BeforeSaveChanges(); (domainEvents, eventStores) = BeforeSaveChanges();
var rowsAffected = await writeDbContext.SaveChangesAsync(); var rowsAffected = await writeDbContext.SaveChangesAsync();
@@ -44,8 +47,7 @@ internal sealed class UnitOfWork(
await transaction.CommitAsync(); await transaction.CommitAsync();
// Triggering the events and saving the stores.
await AfterSaveChangesAsync(domainEvents, eventStores);
logger.LogInformation( logger.LogInformation(
"----- Transaction successfully confirmed: '{TransactionId}', Rows Affected: {RowsAffected}", "----- Transaction successfully confirmed: '{TransactionId}', Rows Affected: {RowsAffected}",
@@ -64,6 +66,9 @@ internal sealed class UnitOfWork(
throw; throw;
} }
// Triggering the events and saving the stores.
await AfterSaveChangesAsync(domainEvents, eventStores);
}); });
} }
@@ -89,7 +89,7 @@ internal static class ServicesCollectionExtensions
var envIsDevelopment = environment.IsDevelopment(); var envIsDevelopment = environment.IsDevelopment();
optionsBuilder optionsBuilder
.UseSqlServer(connectionOptions.SqlConnection, sqlServerOptions => .UseNpgsql(connectionOptions.PostgresConnection, sqlServerOptions =>
{ {
sqlServerOptions sqlServerOptions
.MigrationsAssembly(DbMigrationAssemblyName) .MigrationsAssembly(DbMigrationAssemblyName)
@@ -1,89 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Shop.Infrastructure.Data.Context;
#nullable disable
namespace Shop.PublicApi.Migrations
{
[DbContext(typeof(WriteDbContext))]
[Migration("20230207164309_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseCollation("Latin1_General_CI_AI")
.HasAnnotation("ProductVersion", "7.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Shop.Domain.Entities.Customer.Customer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateOfBirth")
.HasColumnType("DATE");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnType("varchar(100)");
b.Property<string>("Gender")
.IsRequired()
.HasMaxLength(6)
.IsUnicode(false)
.HasColumnType("varchar(6)");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnType("varchar(100)");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("Shop.Domain.Entities.Customer.Customer", b =>
{
b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 =>
{
b1.Property<Guid>("CustomerId")
.HasColumnType("uniqueidentifier");
b1.Property<string>("Address")
.IsRequired()
.HasMaxLength(254)
.IsUnicode(false)
.HasColumnType("varchar(254)")
.HasColumnName("Email");
b1.HasKey("CustomerId");
b1.HasIndex("Address")
.IsUnique()
.HasFilter("[Email] IS NOT NULL");
b1.ToTable("Customers");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.Navigation("Email");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,39 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Shop.PublicApi.Migrations;
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
FirstName = table.Column<string>(type: "varchar(100)", unicode: false, maxLength: 100, nullable: false),
LastName = table.Column<string>(type: "varchar(100)", unicode: false, maxLength: 100, nullable: false),
Gender = table.Column<string>(type: "varchar(6)", unicode: false, maxLength: 6, nullable: false),
Email = table.Column<string>(type: "varchar(254)", unicode: false, maxLength: 254, nullable: true),
DateOfBirth = table.Column<DateTime>(type: "DATE", nullable: false)
},
constraints: table => table.PrimaryKey("PK_Customers", x => x.Id));
migrationBuilder.CreateIndex(
name: "IX_Customers_Email",
table: "Customers",
column: "Email",
unique: true,
filter: "[Email] IS NOT NULL");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Customers");
}
}
@@ -1,39 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shop.PublicApi.Migrations;
/// <inheritdoc />
public partial class EF_Update : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Gender",
table: "Customers",
type: "nvarchar(6)",
maxLength: 6,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(6)",
oldUnicode: false,
oldMaxLength: 6);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Gender",
table: "Customers",
type: "varchar(6)",
unicode: false,
maxLength: 6,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(6)",
oldMaxLength: 6);
}
}
@@ -2,9 +2,9 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Shop.Infrastructure.Data.Context; using Shop.Infrastructure.Data.Context;
#nullable disable #nullable disable
@@ -12,24 +12,23 @@ using Shop.Infrastructure.Data.Context;
namespace Shop.PublicApi.Migrations namespace Shop.PublicApi.Migrations
{ {
[DbContext(typeof(WriteDbContext))] [DbContext(typeof(WriteDbContext))]
[Migration("20241128202054_EF_Update")] [Migration("20250924110748_Initial")]
partial class EF_Update partial class Initial
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.UseCollation("Latin1_General_CI_AI") .HasAnnotation("ProductVersion", "9.0.9")
.HasAnnotation("ProductVersion", "9.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63);
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b => modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b.Property<DateTime>("DateOfBirth") b.Property<DateTime>("DateOfBirth")
.HasColumnType("DATE"); .HasColumnType("DATE");
@@ -38,18 +37,18 @@ namespace Shop.PublicApi.Migrations
.IsRequired() .IsRequired()
.HasMaxLength(100) .HasMaxLength(100)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(100)"); .HasColumnType("character varying(100)");
b.Property<string>("Gender") b.Property<string>("Gender")
.IsRequired() .IsRequired()
.HasMaxLength(6) .HasMaxLength(6)
.HasColumnType("nvarchar(6)"); .HasColumnType("character varying(6)");
b.Property<string>("LastName") b.Property<string>("LastName")
.IsRequired() .IsRequired()
.HasMaxLength(100) .HasMaxLength(100)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(100)"); .HasColumnType("character varying(100)");
b.HasKey("Id"); b.HasKey("Id");
@@ -61,20 +60,19 @@ namespace Shop.PublicApi.Migrations
b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 => b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 =>
{ {
b1.Property<Guid>("CustomerId") b1.Property<Guid>("CustomerId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b1.Property<string>("Address") b1.Property<string>("Address")
.IsRequired() .IsRequired()
.HasMaxLength(254) .HasMaxLength(254)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(254)") .HasColumnType("character varying(254)")
.HasColumnName("Email"); .HasColumnName("Email");
b1.HasKey("CustomerId"); b1.HasKey("CustomerId");
b1.HasIndex("Address") b1.HasIndex("Address")
.IsUnique() .IsUnique();
.HasFilter("[Email] IS NOT NULL");
b1.ToTable("Customers"); b1.ToTable("Customers");
@@ -0,0 +1,44 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shop.PublicApi.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
FirstName = table.Column<string>(type: "character varying(100)", unicode: false, maxLength: 100, nullable: false),
LastName = table.Column<string>(type: "character varying(100)", unicode: false, maxLength: 100, nullable: false),
Gender = table.Column<string>(type: "character varying(6)", maxLength: 6, nullable: false),
Email = table.Column<string>(type: "character varying(254)", unicode: false, maxLength: 254, nullable: true),
DateOfBirth = table.Column<DateTime>(type: "DATE", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Customers_Email",
table: "Customers",
column: "Email",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Customers");
}
}
}
@@ -1,58 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Shop.Infrastructure.Data.Context;
#nullable disable
namespace Shop.PublicApi.Migrations.EventStoreDb
{
[DbContext(typeof(EventStoreDbContext))]
[Migration("20230226145437_EventStore")]
partial class EventStore
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseCollation("Latin1_General_CI_AI")
.HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Shop.Core.Events.EventStore", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("AggregateId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Data")
.IsRequired()
.IsUnicode(false)
.HasColumnType("VARCHAR(MAX)")
.HasComment("JSON serialized event");
b.Property<string>("MessageType")
.IsRequired()
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnType("varchar(100)");
b.Property<DateTime>("OccurredOn")
.HasColumnType("datetime2")
.HasColumnName("CreatedAt");
b.HasKey("Id");
b.ToTable("EventStores");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,31 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Shop.PublicApi.Migrations.EventStoreDb;
/// <inheritdoc />
public partial class EventStore : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "EventStores",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Data = table.Column<string>(type: "VARCHAR(MAX)", unicode: false, nullable: false, comment: "JSON serialized event"),
MessageType = table.Column<string>(type: "varchar(100)", unicode: false, maxLength: 100, nullable: false),
AggregateId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table => table.PrimaryKey("PK_EventStores", x => x.Id));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EventStores");
}
}
@@ -1,43 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shop.PublicApi.Migrations.EventStoreDb;
/// <inheritdoc />
public partial class EF_Update : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "EventStores",
type: "varchar(255)",
unicode: false,
maxLength: 255,
nullable: false,
oldClrType: typeof(string),
oldType: "VARCHAR(MAX)",
oldUnicode: false,
comment: "JSON serialized event",
oldComment: "JSON serialized event");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "EventStores",
type: "VARCHAR(MAX)",
unicode: false,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)",
oldUnicode: false,
oldMaxLength: 255,
comment: "JSON serialized event",
oldComment: "JSON serialized event");
}
}
@@ -2,53 +2,52 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Shop.Infrastructure.Data.Context; using Shop.Infrastructure.Data.Context;
#nullable disable #nullable disable
namespace Shop.PublicApi.Migrations.EventStoreDb namespace Shop.PublicApi.Migrations.EventStoreMigrations
{ {
[DbContext(typeof(EventStoreDbContext))] [DbContext(typeof(EventStoreDbContext))]
[Migration("20241128202230_EF_Update")] [Migration("20250924110826_Initial")]
partial class EF_Update partial class Initial
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.UseCollation("Latin1_General_CI_AI") .HasAnnotation("ProductVersion", "9.0.9")
.HasAnnotation("ProductVersion", "9.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63);
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Shop.Core.SharedKernel.EventStore", b => modelBuilder.Entity("Shop.Core.SharedKernel.EventStore", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b.Property<Guid>("AggregateId") b.Property<Guid>("AggregateId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b.Property<string>("Data") b.Property<string>("Data")
.IsRequired() .IsRequired()
.HasMaxLength(255) .HasMaxLength(255)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(255)") .HasColumnType("character varying(255)")
.HasComment("JSON serialized event"); .HasComment("JSON serialized event");
b.Property<string>("MessageType") b.Property<string>("MessageType")
.IsRequired() .IsRequired()
.HasMaxLength(100) .HasMaxLength(100)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(100)"); .HasColumnType("character varying(100)");
b.Property<DateTime>("OccurredOn") b.Property<DateTime>("OccurredOn")
.HasColumnType("datetime2") .HasColumnType("timestamp with time zone")
.HasColumnName("CreatedAt"); .HasColumnName("CreatedAt");
b.HasKey("Id"); b.HasKey("Id");
@@ -0,0 +1,37 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shop.PublicApi.Migrations.EventStoreMigrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "EventStores",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Data = table.Column<string>(type: "character varying(255)", unicode: false, maxLength: 255, nullable: false, comment: "JSON serialized event"),
MessageType = table.Column<string>(type: "character varying(100)", unicode: false, maxLength: 100, nullable: false),
AggregateId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EventStores", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EventStores");
}
}
}
@@ -2,13 +2,13 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Shop.Infrastructure.Data.Context; using Shop.Infrastructure.Data.Context;
#nullable disable #nullable disable
namespace Shop.PublicApi.Migrations.EventStoreDb namespace Shop.PublicApi.Migrations.EventStoreMigrations
{ {
[DbContext(typeof(EventStoreDbContext))] [DbContext(typeof(EventStoreDbContext))]
partial class EventStoreDbContextModelSnapshot : ModelSnapshot partial class EventStoreDbContextModelSnapshot : ModelSnapshot
@@ -17,35 +17,34 @@ namespace Shop.PublicApi.Migrations.EventStoreDb
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.UseCollation("Latin1_General_CI_AI") .HasAnnotation("ProductVersion", "9.0.9")
.HasAnnotation("ProductVersion", "9.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63);
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Shop.Core.SharedKernel.EventStore", b => modelBuilder.Entity("Shop.Core.SharedKernel.EventStore", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b.Property<Guid>("AggregateId") b.Property<Guid>("AggregateId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b.Property<string>("Data") b.Property<string>("Data")
.IsRequired() .IsRequired()
.HasMaxLength(255) .HasMaxLength(255)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(255)") .HasColumnType("character varying(255)")
.HasComment("JSON serialized event"); .HasComment("JSON serialized event");
b.Property<string>("MessageType") b.Property<string>("MessageType")
.IsRequired() .IsRequired()
.HasMaxLength(100) .HasMaxLength(100)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(100)"); .HasColumnType("character varying(100)");
b.Property<DateTime>("OccurredOn") b.Property<DateTime>("OccurredOn")
.HasColumnType("datetime2") .HasColumnType("timestamp with time zone")
.HasColumnName("CreatedAt"); .HasColumnName("CreatedAt");
b.HasKey("Id"); b.HasKey("Id");
@@ -2,8 +2,8 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Shop.Infrastructure.Data.Context; using Shop.Infrastructure.Data.Context;
#nullable disable #nullable disable
@@ -17,16 +17,15 @@ namespace Shop.PublicApi.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.UseCollation("Latin1_General_CI_AI") .HasAnnotation("ProductVersion", "9.0.9")
.HasAnnotation("ProductVersion", "9.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63);
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b => modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b.Property<DateTime>("DateOfBirth") b.Property<DateTime>("DateOfBirth")
.HasColumnType("DATE"); .HasColumnType("DATE");
@@ -35,18 +34,18 @@ namespace Shop.PublicApi.Migrations
.IsRequired() .IsRequired()
.HasMaxLength(100) .HasMaxLength(100)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(100)"); .HasColumnType("character varying(100)");
b.Property<string>("Gender") b.Property<string>("Gender")
.IsRequired() .IsRequired()
.HasMaxLength(6) .HasMaxLength(6)
.HasColumnType("nvarchar(6)"); .HasColumnType("character varying(6)");
b.Property<string>("LastName") b.Property<string>("LastName")
.IsRequired() .IsRequired()
.HasMaxLength(100) .HasMaxLength(100)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(100)"); .HasColumnType("character varying(100)");
b.HasKey("Id"); b.HasKey("Id");
@@ -58,20 +57,19 @@ namespace Shop.PublicApi.Migrations
b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 => b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 =>
{ {
b1.Property<Guid>("CustomerId") b1.Property<Guid>("CustomerId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uuid");
b1.Property<string>("Address") b1.Property<string>("Address")
.IsRequired() .IsRequired()
.HasMaxLength(254) .HasMaxLength(254)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("varchar(254)") .HasColumnType("character varying(254)")
.HasColumnName("Email"); .HasColumnName("Email");
b1.HasKey("CustomerId"); b1.HasKey("CustomerId");
b1.HasIndex("Address") b1.HasIndex("Address")
.IsUnique() .IsUnique();
.HasFilter("[Email] IS NOT NULL");
b1.ToTable("Customers"); b1.ToTable("Customers");
+1
View File
@@ -1,3 +1,4 @@
using System;
using System.Globalization; using System.Globalization;
using System.IO.Compression; using System.IO.Compression;
using Asp.Versioning; using Asp.Versioning;
+1
View File
@@ -40,6 +40,7 @@
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" /> <PackageReference Include="MiniProfiler.AspNetCore.Mvc" />
<PackageReference Include="MiniProfiler.EntityFrameworkCore" /> <PackageReference Include="MiniProfiler.EntityFrameworkCore" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" />
<PackageReference Include="Roslynator.Analyzers"> <PackageReference Include="Roslynator.Analyzers">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+6
View File
@@ -6,5 +6,11 @@
"Microsoft.Hosting.Lifetime": "Information" "Microsoft.Hosting.Lifetime": "Information"
} }
}, },
"ConnectionStrings": {
"PostgresConnection" : "Host=localhost;Port=5432;Database=ShopDDD;Username=mmdi;Password=mmdi",
"SqlConnection": "Server=localhost,1433;Database=ShopContext;User Id=sa;Password=Programmer.369;TrustServerCertificate=True;",
"NoSqlConnection" : "mongodb://localhost:27017",
"CacheConnection" : "localhost:6379,password=Programmer.369,abortConnect=false"
},
"AllowedHosts": "*" "AllowedHosts": "*"
} }