From 3905094ff4f8857bba61a71e571b567981461718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B0=D0=BB=D0=B8=D0=BC=D0=BE=D0=B2=20=D0=A0=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BC?= Date: Tue, 7 Apr 2026 21:22:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=BC?= =?UTF-8?q?=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20260407181656_AddUserInfoFields.cs | 64 +++++-------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/backend/src/Modules/Auth/Migrations/20260407181656_AddUserInfoFields.cs b/backend/src/Modules/Auth/Migrations/20260407181656_AddUserInfoFields.cs index 1d17877..eb35b6e 100644 --- a/backend/src/Modules/Auth/Migrations/20260407181656_AddUserInfoFields.cs +++ b/backend/src/Modules/Auth/Migrations/20260407181656_AddUserInfoFields.cs @@ -1,4 +1,4 @@ -using System; +using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -8,60 +8,30 @@ namespace Knot.Modules.Auth.Migrations /// public partial class AddUserInfoFields : Migration { - /// protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AddColumn( - name: "BannedUntil", - schema: "identity", - table: "Users", - type: "timestamp with time zone", - nullable: true); + migrationBuilder.Sql(@" + DO $$ + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='identity' AND table_name='Users' AND column_name='BannedUntil') THEN + ALTER TABLE identity.""Users"" ADD ""BannedUntil"" timestamp with time zone; + END IF; - migrationBuilder.AddColumn( - name: "PhoneNumber", - schema: "identity", - table: "Users", - type: "text", - nullable: true); + IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='identity' AND table_name='Users' AND column_name='PhoneNumber') THEN + ALTER TABLE identity.""Users"" ADD ""PhoneNumber"" text; + END IF; - migrationBuilder.AddColumn( - name: "RefreshToken", - schema: "identity", - table: "Users", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "UserDomain", - schema: "identity", - table: "Users", - type: "text", - nullable: true); + IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='identity' AND table_name='Users' AND column_name='RefreshToken') THEN + ALTER TABLE identity.""Users"" ADD ""RefreshToken"" text; + END IF; + END $$;"); } - /// protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DropColumn( - name: "BannedUntil", - schema: "identity", - 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"); + migrationBuilder.DropColumn(name: "BannedUntil", schema: "identity", table: "Users"); + migrationBuilder.DropColumn(name: "PhoneNumber", schema: "identity", table: "Users"); + migrationBuilder.DropColumn(name: "RefreshToken", schema: "identity", table: "Users"); } } }