diff --git a/src/UserPointManagement.Model/Entities/User.cs b/src/UserPointManagement.Model/Entities/User.cs index ca12ba6..6336605 100644 --- a/src/UserPointManagement.Model/Entities/User.cs +++ b/src/UserPointManagement.Model/Entities/User.cs @@ -6,5 +6,5 @@ public class User public string Name { get; set; } - public string Mobile { get; set; } + public string? Mobile { get; set; } } \ No newline at end of file diff --git a/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.Designer.cs b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.Designer.cs new file mode 100644 index 0000000..2721dee --- /dev/null +++ b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.Designer.cs @@ -0,0 +1,89 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using UserPointManagement.Persistence; + +#nullable disable + +namespace UserPointManagement.Persistence.Migrations +{ + [DbContext(typeof(UserPointManagementDbContext))] + [Migration("20230730134035_ModifyUser")] + partial class ModifyUser + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("UserPointManagement.Model.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id") + .HasComment("主键"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Mobile") + .HasMaxLength(30) + .HasColumnType("character varying(30)") + .HasColumnName("mobile") + .HasComment("手机号"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("name") + .HasComment("姓名"); + + b.HasKey("Id") + .HasName("pk_user"); + + b.ToTable("user", (string)null); + }); + + modelBuilder.Entity("UserPointManagement.Model.Entities.UserPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id") + .HasComment("主键"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreateTime") + .HasColumnType("timestamp without time zone") + .HasColumnName("create_time") + .HasComment("新增时间"); + + b.Property("Point") + .HasColumnType("integer") + .HasColumnName("point") + .HasComment("积分"); + + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id") + .HasComment("用户Id"); + + b.HasKey("Id") + .HasName("pk_user_point"); + + b.ToTable("user_point", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.cs b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.cs new file mode 100644 index 0000000..89f6326 --- /dev/null +++ b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace UserPointManagement.Persistence.Migrations +{ + public partial class ModifyUser : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "mobile", + table: "user", + type: "character varying(30)", + maxLength: 30, + nullable: true, + comment: "手机号", + oldClrType: typeof(string), + oldType: "character varying(30)", + oldMaxLength: 30, + oldComment: "手机号"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "mobile", + table: "user", + type: "character varying(30)", + maxLength: 30, + nullable: false, + defaultValue: "", + comment: "手机号", + oldClrType: typeof(string), + oldType: "character varying(30)", + oldMaxLength: 30, + oldNullable: true, + oldComment: "手机号"); + } + } +} diff --git a/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs b/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs index ff15431..d3f4674 100644 --- a/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs +++ b/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs @@ -33,7 +33,6 @@ namespace UserPointManagement.Persistence.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Mobile") - .IsRequired() .HasMaxLength(30) .HasColumnType("character varying(30)") .HasColumnName("mobile")