20260218044853_RenameCoinNameToKorEngName.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Microsoft.EntityFrameworkCore.Migrations;
  2. #nullable disable
  3. namespace Infrastructure.Migrations.AppDb
  4. {
  5. /// <inheritdoc />
  6. public partial class RenameCoinNameToKorEngName : Migration
  7. {
  8. /// <inheritdoc />
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.RenameColumn(
  12. name: "Name",
  13. table: "Coin",
  14. newName: "KorName");
  15. migrationBuilder.Sql("""
  16. IF EXISTS (
  17. SELECT 1 FROM sys.extended_properties ep
  18. INNER JOIN sys.columns c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id
  19. WHERE c.object_id = OBJECT_ID('Coin') AND c.name = 'KorName' AND ep.name = 'MS_Description'
  20. )
  21. EXEC sp_dropextendedproperty 'MS_Description', 'SCHEMA', 'dbo', 'TABLE', 'Coin', 'COLUMN', 'KorName';
  22. """);
  23. migrationBuilder.AlterColumn<string>(
  24. name: "KorName",
  25. table: "Coin",
  26. type: "nvarchar(200)",
  27. maxLength: 200,
  28. nullable: false,
  29. comment: "한글 이름");
  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. }
  66. }
  67. }