Skip to content

Commit

Permalink
fix: postgres migrations and add sql server migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-almeida-konkconsulting committed Jun 21, 2024
1 parent 51ff549 commit 5800009
Show file tree
Hide file tree
Showing 26 changed files with 3,625 additions and 60 deletions.

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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ public partial class IdentityAddress_Varying_Length : Migration
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress",
schema: "Devices",
table: "IdentityDeletionProcesses");

migrationBuilder.DropForeignKey(
name: "FK_Devices_Identities_IdentityAddress",
schema: "Devices",
table: "Devices");

migrationBuilder.DropPrimaryKey(
name: "PK_Identities",
schema: "Devices",
table: "Identities");

migrationBuilder.AlterColumn<string>(
name: "IdentityAddress",
schema: "Devices",
Expand Down Expand Up @@ -66,11 +81,51 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldUnicode: false,
oldFixedLength: true,
oldMaxLength: 80);

migrationBuilder.AddPrimaryKey(
name: "PK_Identities",
schema: "Devices",
table: "Identities",
column: "Address");

migrationBuilder.AddForeignKey(
name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress",
schema: "Devices",
table: "IdentityDeletionProcesses",
column: "IdentityAddress",
principalTable: "Identities",
principalSchema: "Devices",
principalColumn: "Address");

migrationBuilder.AddForeignKey(
name: "FK_Devices_Identities_IdentityAddress",
schema: "Devices",
table: "Devices",
column: "IdentityAddress",
principalTable: "Identities",
principalSchema: "Devices",
principalColumn: "Address",
onDelete: ReferentialAction.Cascade);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress",
schema: "Devices",
table: "IdentityDeletionProcesses");

migrationBuilder.DropForeignKey(
name: "FK_Devices_Identities_IdentityAddress",
schema: "Devices",
table: "Devices");

migrationBuilder.DropPrimaryKey(
name: "PK_Identities",
schema: "Devices",
table: "Identities");

migrationBuilder.AlterColumn<string>(
name: "IdentityAddress",
schema: "Devices",
Expand Down Expand Up @@ -127,6 +182,31 @@ protected override void Down(MigrationBuilder migrationBuilder)
oldType: "character varying(80)",
oldUnicode: false,
oldMaxLength: 80);

migrationBuilder.AddPrimaryKey(
name: "PK_Identities",
schema: "Devices",
table: "Identities",
column: "Address");

migrationBuilder.AddForeignKey(
name: "FK_IdentityDeletionProcesses_Identities_IdentityAddress",
schema: "Devices",
table: "IdentityDeletionProcesses",
column: "IdentityAddress",
principalTable: "Identities",
principalSchema: "Devices",
principalColumn: "Address");

migrationBuilder.AddForeignKey(
name: "FK_Devices_Identities_IdentityAddress",
schema: "Devices",
table: "Devices",
column: "IdentityAddress",
principalTable: "Identities",
principalSchema: "Devices",
principalColumn: "Address",
onDelete: ReferentialAction.Cascade);
}
}
}
Loading

0 comments on commit 5800009

Please sign in to comment.