Skip to content

Commit

Permalink
Identity Address in database is filled with blanks up to 80 characters (
Browse files Browse the repository at this point in the history
#711)

* refactor: change identity address database type and generate postgres migrations

* fix: postgres migrations and add sql server migrations
  • Loading branch information
daniel-almeida-konkconsulting authored Jun 24, 2024
1 parent ec3b283 commit 31b5263
Show file tree
Hide file tree
Showing 53 changed files with 6,826 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected override void ConfigureConventions(ModelConfigurationBuilder configura
{
base.ConfigureConventions(configurationBuilder);

configurationBuilder.Properties<IdentityAddress>().AreUnicode(false).AreFixedLength().HaveMaxLength(IdentityAddress.MAX_LENGTH).HaveConversion<IdentityAddressValueConverter>();
configurationBuilder.Properties<IdentityAddress>().AreUnicode(false).AreFixedLength(false).HaveMaxLength(IdentityAddress.MAX_LENGTH).HaveConversion<IdentityAddressValueConverter>();
configurationBuilder.Properties<DeviceId>().AreUnicode(false).AreFixedLength().HaveMaxLength(DeviceId.MAX_LENGTH).HaveConversion<DeviceIdValueConverter>();
configurationBuilder.Properties<Username>().AreUnicode(false).AreFixedLength().HaveMaxLength(Username.MAX_LENGTH).HaveConversion<UsernameValueConverter>();

Expand Down
2 changes: 2 additions & 0 deletions ConsumerApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"Devices": {
"Application": {
"InstanceUrl": "localhost",
"Pagination": {
"DefaultPageSize": 50,
"MaxPageSize": 200
Expand All @@ -44,6 +45,7 @@
},
"Messages": {
"Application": {
"InstanceUrl": "localhost",
"MaxNumberOfUnreceivedMessagesFromOneSender": 20,
"Pagination": {
"DefaultPageSize": 50,
Expand Down
6 changes: 5 additions & 1 deletion ConsumerApi/appsettings.override.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
// "ConnectionString": "Server=localhost;Database=enmeshed;User Id=sa;Password=Passw0rd;TrustServerCertificate=True" // sqlserver
},
"PushNotifications": {
"Provider": "Dummy"
"Providers": {
"Dummy": {
"Enabled": "true"
}
}
}
}
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Backbone.Modules.Challenges.Infrastructure.Database.Postgres.Migrations
{
/// <inheritdoc />
public partial class IdentityAddresses_Varying_Length : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "Challenges",
table: "Challenges",
type: "character varying(80)",
unicode: false,
maxLength: 80,
nullable: true,
oldClrType: typeof(string),
oldType: "character(80)",
oldUnicode: false,
oldFixedLength: true,
oldMaxLength: 80,
oldNullable: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "Challenges",
table: "Challenges",
type: "character(80)",
unicode: false,
fixedLength: true,
maxLength: 80,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(80)",
oldUnicode: false,
oldMaxLength: 80,
oldNullable: true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Challenges")
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);

NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
Expand All @@ -34,8 +34,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("CreatedBy")
.HasMaxLength(80)
.IsUnicode(false)
.HasColumnType("character(80)")
.IsFixedLength();
.HasColumnType("character varying(80)")
.IsFixedLength(false);

b.Property<string>("CreatedByDevice")
.HasMaxLength(20)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Backbone.Modules.Challenges.Infrastructure.Database.SqlServer.Migrations
{
/// <inheritdoc />
public partial class IdentityAddress_Varying_Length : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "Challenges",
table: "Challenges",
type: "varchar(80)",
unicode: false,
maxLength: 80,
nullable: true,
oldClrType: typeof(string),
oldType: "char(80)",
oldUnicode: false,
oldFixedLength: true,
oldMaxLength: 80,
oldNullable: true);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "CreatedBy",
schema: "Challenges",
table: "Challenges",
type: "char(80)",
unicode: false,
fixedLength: true,
maxLength: 80,
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(80)",
oldUnicode: false,
oldMaxLength: 80,
oldNullable: true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Challenges")
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
Expand All @@ -34,8 +34,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("CreatedBy")
.HasMaxLength(80)
.IsUnicode(false)
.HasColumnType("char(80)")
.IsFixedLength();
.HasColumnType("varchar(80)")
.IsFixedLength(false);

b.Property<string>("CreatedByDevice")
.HasMaxLength(20)
Expand Down
Loading

0 comments on commit 31b5263

Please sign in to comment.