From 43520544ed538e4f7c4bf8e785a92da9c3be8288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A8=D0=B8?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Tue, 19 Dec 2023 17:36:46 +0300 Subject: [PATCH] change int to ulong discord id --- Controllers/HomeController.cs | 2 +- ...1219143602_Migrate191220231734.Designer.cs | 143 ++++++++++++++++++ .../20231219143602_Migrate191220231734.cs | 70 +++++++++ Migrations/AppDbContextModelSnapshot.cs | 6 +- 4 files changed, 216 insertions(+), 5 deletions(-) create mode 100644 Migrations/20231219143602_Migrate191220231734.Designer.cs create mode 100644 Migrations/20231219143602_Migrate191220231734.cs diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 697c39b..ebe4c21 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -100,7 +100,7 @@ namespace yaflay.ru.Новая_папка { Author author = new() { - discordId = int.Parse(response["user"]["id"].ToString()), + discordId = ulong.Parse(response["user"]["id"].ToString()), discordNickName = response["user"]["display_name"].ToString() }; Blogs article = new() diff --git a/Migrations/20231219143602_Migrate191220231734.Designer.cs b/Migrations/20231219143602_Migrate191220231734.Designer.cs new file mode 100644 index 0000000..b5def8a --- /dev/null +++ b/Migrations/20231219143602_Migrate191220231734.Designer.cs @@ -0,0 +1,143 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using yaflay.ru.Models; + +#nullable disable + +namespace yaflay.ru.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20231219143602_Migrate191220231734")] + partial class Migrate191220231734 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.12") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("yaflay.ru.Models.Tables.Author", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("discordId") + .HasColumnType("numeric(20,0)"); + + b.Property("discordNickName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Author"); + }); + + modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Annotation") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImageUrl") + .HasColumnType("text"); + + b.Property("Text") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("authorId") + .HasColumnType("integer"); + + b.Property("dateTime") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("authorId"); + + b.ToTable("Blogs", "public"); + }); + + modelBuilder.Entity("yaflay.ru.Models.Tables.Comments", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Text") + .IsRequired() + .HasColumnType("text"); + + b.Property("creatorMail") + .IsRequired() + .HasColumnType("text"); + + b.Property("dateTime") + .HasColumnType("bigint"); + + b.Property("postId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Comments", "public"); + }); + + modelBuilder.Entity("yaflay.ru.Models.Tables.Redirects", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("redirectTo") + .HasColumnType("text"); + + b.Property("uri") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Redirects"); + }); + + modelBuilder.Entity("yaflay.ru.Models.Tables.Blogs", b => + { + b.HasOne("yaflay.ru.Models.Tables.Author", "author") + .WithMany() + .HasForeignKey("authorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("author"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20231219143602_Migrate191220231734.cs b/Migrations/20231219143602_Migrate191220231734.cs new file mode 100644 index 0000000..113c98d --- /dev/null +++ b/Migrations/20231219143602_Migrate191220231734.cs @@ -0,0 +1,70 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace yaflay.ru.Migrations +{ + /// + public partial class Migrate191220231734 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "uri", + table: "Redirects", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "redirectTo", + table: "Redirects", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "discordId", + table: "Author", + type: "numeric(20,0)", + nullable: false, + oldClrType: typeof(int), + oldType: "integer"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "uri", + table: "Redirects", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "redirectTo", + table: "Redirects", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "discordId", + table: "Author", + type: "integer", + nullable: false, + oldClrType: typeof(decimal), + oldType: "numeric(20,0)"); + } + } +} diff --git a/Migrations/AppDbContextModelSnapshot.cs b/Migrations/AppDbContextModelSnapshot.cs index 40932c2..37fb8f0 100644 --- a/Migrations/AppDbContextModelSnapshot.cs +++ b/Migrations/AppDbContextModelSnapshot.cs @@ -30,8 +30,8 @@ namespace yaflay.ru.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("discordId") - .HasColumnType("integer"); + b.Property("discordId") + .HasColumnType("numeric(20,0)"); b.Property("discordNickName") .IsRequired() @@ -114,11 +114,9 @@ namespace yaflay.ru.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("redirectTo") - .IsRequired() .HasColumnType("text"); b.Property("uri") - .IsRequired() .HasColumnType("text"); b.HasKey("Id");