Поля Email и Phone стали nullable

This commit is contained in:
Olga Nemt 2023-11-10 14:50:20 +05:00
parent b2d6091476
commit bd43d7b525
5 changed files with 8963 additions and 6 deletions

View File

@ -35,13 +35,13 @@ namespace AsbCloudApp.Data.User
/// Email
/// </summary>
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")]
public string Email { get; set; } = null!;
public string? Email { get; set; }
/// <summary>
/// Phone
/// </summary>
[RegularExpression(@"^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$", ErrorMessage = "Некорректный номер телефона")]
public string Phone { get; set; } = null!;
public string? Phone { get; set; }
/// <summary>
/// Должность

View File

@ -0,0 +1,67 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class UpdateTable_t_contact_Set_Email_and_Phone_Nullable : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "phone",
table: "t_contact",
type: "character varying(50)",
maxLength: 50,
nullable: true,
comment: "номер телефона",
oldClrType: typeof(string),
oldType: "character varying(50)",
oldMaxLength: 50,
oldComment: "номер телефона");
migrationBuilder.AlterColumn<string>(
name: "email",
table: "t_contact",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "email",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "email");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "phone",
table: "t_contact",
type: "character varying(50)",
maxLength: 50,
nullable: false,
defaultValue: "",
comment: "номер телефона",
oldClrType: typeof(string),
oldType: "character varying(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "номер телефона");
migrationBuilder.AlterColumn<string>(
name: "email",
table: "t_contact",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "email",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "email");
}
}
}

View File

@ -214,7 +214,6 @@ namespace AsbCloudDb.Migrations
.HasComment("компания");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)")
.HasColumnName("email")
@ -240,7 +239,6 @@ namespace AsbCloudDb.Migrations
.HasComment("ключ скважины");
b.Property<string>("Phone")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)")
.HasColumnName("phone")

View File

@ -26,11 +26,11 @@ namespace AsbCloudDb.Model
[Column("email"), Comment("email")]
[StringLength(255)]
public string Email { get; set; } = string.Empty;
public string? Email { get; set; }
[Column("phone"), Comment("номер телефона")]
[StringLength(50)]
public string Phone { get; set; } = string.Empty;
public string? Phone { get; set; }
[Column("position"), Comment("должность")]
[StringLength(255)]