DD.WellWorkover.Cloud/AsbCloudDb/Migrations/20230220062152_Enable_nullable_on_user_userRole.cs

144 lines
5.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class Enable_nullable_on_user_userRole : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("update t_user set email = '' where email is null;");
migrationBuilder.Sql("update t_user set password_hash = '' where password_hash is null;");
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_user_role",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "Название");
migrationBuilder.AlterColumn<string>(
name: "password_hash",
table: "t_user",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "соленый хэш пароля.\nпервые 5 символов - соль",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "соленый хэш пароля.\nпервые 5 символов - соль");
migrationBuilder.AlterColumn<string>(
name: "login",
table: "t_user",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "id_company",
table: "t_user",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "email",
table: "t_user",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
comment: "должность",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true,
oldComment: "должность");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "caption",
table: "t_user_role",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "Название",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "Название");
migrationBuilder.AlterColumn<string>(
name: "password_hash",
table: "t_user",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "соленый хэш пароля.\nпервые 5 символов - соль",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "соленый хэш пароля.\nпервые 5 символов - соль");
migrationBuilder.AlterColumn<string>(
name: "login",
table: "t_user",
type: "character varying(255)",
maxLength: 255,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255);
migrationBuilder.AlterColumn<int>(
name: "id_company",
table: "t_user",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<string>(
name: "email",
table: "t_user",
type: "character varying(255)",
maxLength: 255,
nullable: true,
comment: "должность",
oldClrType: typeof(string),
oldType: "character varying(255)",
oldMaxLength: 255,
oldComment: "должность");
migrationBuilder.UpdateData(
table: "t_user",
keyColumn: "id",
keyValue: 1,
column: "email",
value: null);
}
}
}