feat(tipping): add string max_length constraint migration

This commit is contained in:
2025-07-31 13:52:45 -04:00
parent c1d44fde49
commit d7eff20050
3 changed files with 193 additions and 5 deletions

View File

@@ -0,0 +1,84 @@
// <auto-generated />
using System;
using Hutopy.Modules.Tipping.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Hutopy.Modules.Tipping.Migrations
{
[DbContext(typeof(TippingDbContext))]
[Migration("20250731175148_TippingIssues")]
partial class TippingIssues
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Tipping")
.HasAnnotation("ProductVersion", "9.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Hutopy.Modules.Tipping.Data.Tip", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<decimal>("Amount")
.HasColumnType("numeric");
b.Property<DateTimeOffset>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
b.Property<Guid>("CreatedBy")
.HasColumnType("uuid");
b.Property<Guid>("CreatorId")
.HasColumnType("uuid");
b.Property<string>("Currency")
.IsRequired()
.HasMaxLength(8)
.HasColumnType("character varying(8)");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("DeletedBy")
.HasColumnType("uuid");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<short>("Status")
.HasColumnType("smallint");
b.Property<string>("StripeInvoiceUrl")
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("StripeSessionId")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");
b.ToTable("Tips", "Tipping");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,100 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Hutopy.Modules.Tipping.Migrations
{
/// <inheritdoc />
public partial class TippingIssues : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "StripeSessionId",
schema: "Tipping",
table: "Tips",
type: "character varying(256)",
maxLength: 256,
nullable: false,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "StripeInvoiceUrl",
schema: "Tipping",
table: "Tips",
type: "character varying(2048)",
maxLength: 2048,
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Message",
schema: "Tipping",
table: "Tips",
type: "character varying(2048)",
maxLength: 2048,
nullable: false,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Currency",
schema: "Tipping",
table: "Tips",
type: "character varying(8)",
maxLength: 8,
nullable: false,
oldClrType: typeof(string),
oldType: "text");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "StripeSessionId",
schema: "Tipping",
table: "Tips",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(256)",
oldMaxLength: 256);
migrationBuilder.AlterColumn<string>(
name: "StripeInvoiceUrl",
schema: "Tipping",
table: "Tips",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(2048)",
oldMaxLength: 2048,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Message",
schema: "Tipping",
table: "Tips",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(2048)",
oldMaxLength: 2048);
migrationBuilder.AlterColumn<string>(
name: "Currency",
schema: "Tipping",
table: "Tips",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(8)",
oldMaxLength: 8);
}
}
}

View File

@@ -18,7 +18,7 @@ namespace Hutopy.Modules.Tipping.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("Tipping")
.HasAnnotation("ProductVersion", "9.0.3")
.HasAnnotation("ProductVersion", "9.0.6")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -45,7 +45,8 @@ namespace Hutopy.Modules.Tipping.Migrations
b.Property<string>("Currency")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(8)
.HasColumnType("character varying(8)");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("timestamp with time zone");
@@ -55,17 +56,20 @@ namespace Hutopy.Modules.Tipping.Migrations
b.Property<string>("Message")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<short>("Status")
.HasColumnType("smallint");
b.Property<string>("StripeInvoiceUrl")
.HasColumnType("text");
.HasMaxLength(2048)
.HasColumnType("character varying(2048)");
b.Property<string>("StripeSessionId")
.IsRequired()
.HasColumnType("text");
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.HasKey("Id");