20260420093940_NormalizeChannelHandleStripAtPrefix.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb;
  4. /// <inheritdoc />
  5. public partial class NormalizeChannelHandleStripAtPrefix : Migration
  6. {
  7. /// <inheritdoc />
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. // 기존 저장된 Channel.Handle 값에서 '@' 접두사 제거 (canonical form 통일)
  11. migrationBuilder.Sql(@"
  12. UPDATE [Channel]
  13. SET [Handle] = STUFF([Handle], 1, 1, '')
  14. WHERE [Handle] LIKE N'@%';
  15. ");
  16. // 이력 테이블도 방어적 정규화
  17. migrationBuilder.Sql(@"
  18. UPDATE [ChannelHandleHistory]
  19. SET [OldHandle] = STUFF([OldHandle], 1, 1, '')
  20. WHERE [OldHandle] LIKE N'@%';
  21. ");
  22. }
  23. /// <inheritdoc />
  24. protected override void Down(MigrationBuilder migrationBuilder)
  25. {
  26. // 데이터 정규화는 되돌릴 수 없음 (원본 '@' 접두사 유무를 기억하지 않음) — no-op
  27. }
  28. }