20260218044853_RenameCoinNameToKorEngName.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb;
  4. /// <inheritdoc />
  5. public partial class RenameCoinNameToKorEngName : Migration
  6. {
  7. /// <inheritdoc />
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.RenameColumn(
  11. name: "Name",
  12. table: "Coin",
  13. newName: "KorName");
  14. migrationBuilder.Sql("""
  15. IF EXISTS (
  16. SELECT 1 FROM sys.extended_properties ep
  17. INNER JOIN sys.columns c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id
  18. WHERE c.object_id = OBJECT_ID('Coin') AND c.name = 'KorName' AND ep.name = 'MS_Description'
  19. )
  20. EXEC sp_dropextendedproperty 'MS_Description', 'SCHEMA', 'dbo', 'TABLE', 'Coin', 'COLUMN', 'KorName';
  21. """);
  22. migrationBuilder.AlterColumn<string>(
  23. name: "KorName",
  24. table: "Coin",
  25. type: "nvarchar(200)",
  26. maxLength: 200,
  27. nullable: false,
  28. comment: "한글 이름",
  29. oldComment: "한글 이름");
  30. migrationBuilder.AddColumn<string>(
  31. name: "EngName",
  32. table: "Coin",
  33. type: "nvarchar(200)",
  34. maxLength: 200,
  35. nullable: false,
  36. defaultValue: "",
  37. comment: "영문 이름");
  38. migrationBuilder.Sql("UPDATE [Coin] SET [EngName] = [KorName]");
  39. }
  40. /// <inheritdoc />
  41. protected override void Down(MigrationBuilder migrationBuilder)
  42. {
  43. migrationBuilder.DropColumn(
  44. name: "EngName",
  45. table: "Coin");
  46. migrationBuilder.Sql("""
  47. IF EXISTS (
  48. SELECT 1 FROM sys.extended_properties ep
  49. INNER JOIN sys.columns c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id
  50. WHERE c.object_id = OBJECT_ID('Coin') AND c.name = 'KorName' AND ep.name = 'MS_Description'
  51. )
  52. EXEC sp_dropextendedproperty 'MS_Description', 'SCHEMA', 'dbo', 'TABLE', 'Coin', 'COLUMN', 'KorName';
  53. """);
  54. migrationBuilder.RenameColumn(
  55. name: "KorName",
  56. table: "Coin",
  57. newName: "Name");
  58. migrationBuilder.AlterColumn<string>(
  59. name: "Name",
  60. table: "Coin",
  61. type: "nvarchar(200)",
  62. maxLength: 200,
  63. nullable: false,
  64. comment: "코인 이름",
  65. oldComment: "코인 이름");
  66. }
  67. }