feat: 数据库中手机号可以为空

develop
Yosheng 2023-07-30 21:41:49 +08:00
parent a2dece29c8
commit a2ad57e066
4 changed files with 131 additions and 2 deletions

View File

@ -6,5 +6,5 @@ public class User
public string Name { get; set; }
public string Mobile { get; set; }
public string? Mobile { get; set; }
}

View File

@ -0,0 +1,89 @@
// <auto-generated />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasColumnName("id")
.HasComment("主键");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Mobile")
.HasMaxLength(30)
.HasColumnType("character varying(30)")
.HasColumnName("mobile")
.HasComment("手机号");
b.Property<string>("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<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasColumnName("id")
.HasComment("主键");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamp without time zone")
.HasColumnName("create_time")
.HasComment("新增时间");
b.Property<int>("Point")
.HasColumnType("integer")
.HasColumnName("point")
.HasComment("积分");
b.Property<int>("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
}
}
}

View File

@ -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<string>(
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<string>(
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: "手机号");
}
}
}

View File

@ -33,7 +33,6 @@ namespace UserPointManagement.Persistence.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Mobile")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)")
.HasColumnName("mobile")