Правка миграций

This commit is contained in:
Халимов Рустам
2026-04-07 21:22:38 +03:00
parent 9e8625aea1
commit 3905094ff4
@@ -1,4 +1,4 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable #nullable disable
@@ -8,60 +8,30 @@ namespace Knot.Modules.Auth.Migrations
/// <inheritdoc /> /// <inheritdoc />
public partial class AddUserInfoFields : Migration public partial class AddUserInfoFields : Migration
{ {
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.AddColumn<DateTime>( migrationBuilder.Sql(@"
name: "BannedUntil", DO $$
schema: "identity", BEGIN
table: "Users", IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='identity' AND table_name='Users' AND column_name='BannedUntil') THEN
type: "timestamp with time zone", ALTER TABLE identity.""Users"" ADD ""BannedUntil"" timestamp with time zone;
nullable: true); END IF;
migrationBuilder.AddColumn<string>( IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='identity' AND table_name='Users' AND column_name='PhoneNumber') THEN
name: "PhoneNumber", ALTER TABLE identity.""Users"" ADD ""PhoneNumber"" text;
schema: "identity", END IF;
table: "Users",
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>( IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='identity' AND table_name='Users' AND column_name='RefreshToken') THEN
name: "RefreshToken", ALTER TABLE identity.""Users"" ADD ""RefreshToken"" text;
schema: "identity", END IF;
table: "Users", END $$;");
type: "text",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "UserDomain",
schema: "identity",
table: "Users",
type: "text",
nullable: true);
} }
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropColumn( migrationBuilder.DropColumn(name: "BannedUntil", schema: "identity", table: "Users");
name: "BannedUntil", migrationBuilder.DropColumn(name: "PhoneNumber", schema: "identity", table: "Users");
schema: "identity", migrationBuilder.DropColumn(name: "RefreshToken", schema: "identity", table: "Users");
table: "Users");
migrationBuilder.DropColumn(
name: "PhoneNumber",
schema: "identity",
table: "Users");
migrationBuilder.DropColumn(
name: "RefreshToken",
schema: "identity",
table: "Users");
migrationBuilder.DropColumn(
name: "UserDomain",
schema: "identity",
table: "Users");
} }
} }
} }