20260218044853_RenameCoinNameToKorEngName.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. migrationBuilder.AddColumn<string>(
  30. name: "EngName",
  31. table: "Coin",
  32. type: "nvarchar(200)",
  33. maxLength: 200,
  34. nullable: false,
  35. defaultValue: "",
  36. comment: "영문 이름");
  37. migrationBuilder.Sql("UPDATE [Coin] SET [EngName] = [KorName]");
  38. }
  39. /// <inheritdoc />
  40. protected override void Down(MigrationBuilder migrationBuilder)
  41. {
  42. migrationBuilder.DropColumn(
  43. name: "EngName",
  44. table: "Coin");
  45. migrationBuilder.Sql("""
  46. IF EXISTS (
  47. SELECT 1 FROM sys.extended_properties ep
  48. INNER JOIN sys.columns c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id
  49. WHERE c.object_id = OBJECT_ID('Coin') AND c.name = 'KorName' AND ep.name = 'MS_Description'
  50. )
  51. EXEC sp_dropextendedproperty 'MS_Description', 'SCHEMA', 'dbo', 'TABLE', 'Coin', 'COLUMN', 'KorName';
  52. """);
  53. migrationBuilder.RenameColumn(
  54. name: "KorName",
  55. table: "Coin",
  56. newName: "Name");
  57. migrationBuilder.AlterColumn<string>(
  58. name: "Name",
  59. table: "Coin",
  60. type: "nvarchar(200)",
  61. maxLength: 200,
  62. nullable: false,
  63. comment: "코인 이름");
  64. }
  65. }