using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations.AppDb
{
///
public partial class AddWidgetTokenToChannel : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "WidgetToken",
table: "Channel",
type: "nvarchar(32)",
maxLength: 32,
nullable: false,
defaultValue: "",
comment: "위젯 토큰");
// 기존 채널에 고유 토큰 생성
migrationBuilder.Sql("UPDATE [Channel] SET [WidgetToken] = LOWER(REPLACE(CAST(NEWID() AS NVARCHAR(36)), '-', ''))");
migrationBuilder.CreateIndex(
name: "IX_Channel_WidgetToken",
table: "Channel",
column: "WidgetToken",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Channel_WidgetToken",
table: "Channel");
migrationBuilder.DropColumn(
name: "WidgetToken",
table: "Channel");
}
}
}