From d5b0473c1f785f9686bee5a6caaf5208365c7883 Mon Sep 17 00:00:00 2001 From: Yoni Lerner Date: Mon, 15 Jan 2024 22:16:42 -0500 Subject: [PATCH] Fix migrations (#68) --- RetakesAllocatorCore/Db/UserSetting.cs | 3 +- .../20240116025022_BigIntTime.Designer.cs | 38 ++++++++++ .../Migrations/20240116025022_BigIntTime.cs | 56 +++++++++++++++ .../Migrations/DbModelSnapshot.cs | 70 +++++++++---------- 4 files changed, 131 insertions(+), 36 deletions(-) create mode 100644 RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.Designer.cs create mode 100644 RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.cs diff --git a/RetakesAllocatorCore/Db/UserSetting.cs b/RetakesAllocatorCore/Db/UserSetting.cs index a352671..08f4a1d 100644 --- a/RetakesAllocatorCore/Db/UserSetting.cs +++ b/RetakesAllocatorCore/Db/UserSetting.cs @@ -19,9 +19,10 @@ public class UserSetting [Key] [Required] [DatabaseGenerated(DatabaseGeneratedOption.None)] + [Column(TypeName = "bigint")] public ulong UserId { get; set; } - [Column(TypeName = "TEXT"), MaxLength(10000)] + [Column(TypeName = "text"), MaxLength(10000)] public WeaponPreferencesType WeaponPreferences { get; set; } = new(); public static void Configure(ModelConfigurationBuilder configurationBuilder) diff --git a/RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.Designer.cs b/RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.Designer.cs new file mode 100644 index 0000000..6c973a4 --- /dev/null +++ b/RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.Designer.cs @@ -0,0 +1,38 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RetakesAllocatorCore.Db; + +#nullable disable + +namespace RetakesAllocator.Migrations +{ + [DbContext(typeof(Db))] + [Migration("20240116025022_BigIntTime")] + partial class BigIntTime + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.14"); + + modelBuilder.Entity("RetakesAllocatorCore.Db.UserSetting", b => + { + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeaponPreferences") + .HasMaxLength(10000) + .HasColumnType("text"); + + b.HasKey("UserId"); + + b.ToTable("UserSettings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.cs b/RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.cs new file mode 100644 index 0000000..04e1ce8 --- /dev/null +++ b/RetakesAllocatorCore/Migrations/20240116025022_BigIntTime.cs @@ -0,0 +1,56 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RetakesAllocator.Migrations +{ + /// + public partial class BigIntTime : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "WeaponPreferences", + table: "UserSettings", + type: "text", + maxLength: 10000, + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 10000, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "UserSettings", + type: "bigint", + nullable: false, + oldClrType: typeof(int), + oldType: "INTEGER"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "WeaponPreferences", + table: "UserSettings", + type: "TEXT", + maxLength: 10000, + nullable: true, + oldClrType: typeof(string), + oldType: "text", + oldMaxLength: 10000, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "UserSettings", + type: "INTEGER", + nullable: false, + oldClrType: typeof(ulong), + oldType: "bigint"); + } + } +} diff --git a/RetakesAllocatorCore/Migrations/DbModelSnapshot.cs b/RetakesAllocatorCore/Migrations/DbModelSnapshot.cs index bbb9ef6..2e2ce6d 100644 --- a/RetakesAllocatorCore/Migrations/DbModelSnapshot.cs +++ b/RetakesAllocatorCore/Migrations/DbModelSnapshot.cs @@ -1,35 +1,35 @@ -// -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using RetakesAllocatorCore.Db; - -#nullable disable - -namespace RetakesAllocator.Migrations -{ - [DbContext(typeof(Db))] - partial class DbModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.14"); - - modelBuilder.Entity("RetakesAllocator.db.UserSetting", b => - { - b.Property("UserId") - .HasColumnType("INTEGER"); - - b.Property("WeaponPreferences") - .HasMaxLength(10000) - .HasColumnType("TEXT"); - - b.HasKey("UserId"); - - b.ToTable("UserSettings", (string)null); - }); -#pragma warning restore 612, 618 - } - } -} +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RetakesAllocatorCore.Db; + +#nullable disable + +namespace RetakesAllocator.Migrations +{ + [DbContext(typeof(Db))] + partial class DbModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.14"); + + modelBuilder.Entity("RetakesAllocatorCore.Db.UserSetting", b => + { + b.Property("UserId") + .HasColumnType("bigint"); + + b.Property("WeaponPreferences") + .HasMaxLength(10000) + .HasColumnType("text"); + + b.HasKey("UserId"); + + b.ToTable("UserSettings"); + }); +#pragma warning restore 612, 618 + } + } +}