using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Migrations.AppDb { /// public partial class RemoveCrypto : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Board_Coin_CoinID", table: "Board"); migrationBuilder.DropTable( name: "CoinCategoryMap"); migrationBuilder.DropTable( name: "CoinMarket"); migrationBuilder.DropTable( name: "CoinCategory"); migrationBuilder.DropTable( name: "Coin"); migrationBuilder.DropIndex( name: "IX_Board_CoinID", table: "Board"); migrationBuilder.DropColumn( name: "CoinID", table: "Board"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "CoinID", table: "Board", type: "int", nullable: true); migrationBuilder.CreateTable( name: "Coin", columns: table => new { ID = table.Column(type: "int", nullable: false, comment: "PK") .Annotation("SqlServer:Identity", "1, 1"), ContractAddress = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true, comment: "컨트랙트 주소"), CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시"), Description = table.Column(type: "nvarchar(max)", nullable: true, comment: "설명"), DisplayOrder = table.Column(type: "smallint", nullable: false, comment: "메인 노출 순서"), EngName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "영문 이름"), IsActive = table.Column(type: "bit", nullable: false, comment: "사용 여부"), IsDelisted = table.Column(type: "bit", nullable: false, comment: "상장 폐지"), IsFeatured = table.Column(type: "bit", nullable: false, comment: "주요 코인 (메인 노출)"), IsNew = table.Column(type: "bit", nullable: false, comment: "신규 상장"), IsWarning = table.Column(type: "bit", nullable: false, comment: "위험 경고"), KorName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false, comment: "한글 이름"), LogoImage = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "로고 이미지"), Symbol = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "심볼 (BTC, ETH 등)"), TelegramUrl = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "텔레그램 URL"), TwitterUrl = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "트위터 URL"), UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시"), WebsiteUrl = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "홈페이지 URL"), WhitepaperUrl = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "백서 URL") }, constraints: table => { table.PrimaryKey("PK_Coin", x => x.ID); }, comment: "코인/토큰"); migrationBuilder.CreateTable( name: "CoinCategory", columns: table => new { ID = table.Column(type: "int", nullable: false, comment: "PK") .Annotation("SqlServer:Identity", "1, 1"), Code = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "카테고리 코드"), CreatedAt = table.Column(type: "datetime2", nullable: false, comment: "등록 일시"), IsActive = table.Column(type: "bit", nullable: false, comment: "사용 여부"), Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false, comment: "카테고리 이름"), Order = table.Column(type: "smallint", nullable: false, comment: "순서"), UpdatedAt = table.Column(type: "datetime2", nullable: true, comment: "수정 일시") }, constraints: table => { table.PrimaryKey("PK_CoinCategory", x => x.ID); }, comment: "코인 카테고리"); migrationBuilder.CreateTable( name: "CoinMarket", columns: table => new { ID = table.Column(type: "int", nullable: false, comment: "PK") .Annotation("SqlServer:Identity", "1, 1"), CoinID = table.Column(type: "int", nullable: false, comment: "코인 ID"), Market = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false, comment: "거래쌍 (KRW-BTC 등)") }, constraints: table => { table.PrimaryKey("PK_CoinMarket", x => x.ID); table.ForeignKey( name: "FK_CoinMarket_Coin_CoinID", column: x => x.CoinID, principalTable: "Coin", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }, comment: "코인-거래쌍 연결"); migrationBuilder.CreateTable( name: "CoinCategoryMap", columns: table => new { ID = table.Column(type: "int", nullable: false, comment: "PK") .Annotation("SqlServer:Identity", "1, 1"), CategoryID = table.Column(type: "int", nullable: false, comment: "카테고리 ID"), CoinID = table.Column(type: "int", nullable: false, comment: "코인 ID") }, constraints: table => { table.PrimaryKey("PK_CoinCategoryMap", x => x.ID); table.ForeignKey( name: "FK_CoinCategoryMap_CoinCategory_CategoryID", column: x => x.CategoryID, principalTable: "CoinCategory", principalColumn: "ID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_CoinCategoryMap_Coin_CoinID", column: x => x.CoinID, principalTable: "Coin", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }, comment: "코인-카테고리 연결"); migrationBuilder.CreateIndex( name: "IX_Board_CoinID", table: "Board", column: "CoinID"); migrationBuilder.CreateIndex( name: "IX_Coin_DisplayOrder", table: "Coin", column: "DisplayOrder"); migrationBuilder.CreateIndex( name: "IX_Coin_IsActive", table: "Coin", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_Coin_IsDelisted", table: "Coin", column: "IsDelisted"); migrationBuilder.CreateIndex( name: "IX_Coin_IsFeatured", table: "Coin", column: "IsFeatured"); migrationBuilder.CreateIndex( name: "IX_Coin_IsNew", table: "Coin", column: "IsNew"); migrationBuilder.CreateIndex( name: "IX_Coin_IsWarning", table: "Coin", column: "IsWarning"); migrationBuilder.CreateIndex( name: "IX_Coin_Symbol", table: "Coin", column: "Symbol", unique: true); migrationBuilder.CreateIndex( name: "IX_Coin_Symbol_IsActive", table: "Coin", columns: new[] { "Symbol", "IsActive" }); migrationBuilder.CreateIndex( name: "IX_CoinCategory_Code", table: "CoinCategory", column: "Code", unique: true); migrationBuilder.CreateIndex( name: "IX_CoinCategory_IsActive", table: "CoinCategory", column: "IsActive"); migrationBuilder.CreateIndex( name: "IX_CoinCategory_Order", table: "CoinCategory", column: "Order"); migrationBuilder.CreateIndex( name: "IX_CoinCategoryMap_CategoryID", table: "CoinCategoryMap", column: "CategoryID"); migrationBuilder.CreateIndex( name: "IX_CoinCategoryMap_CoinID_CategoryID", table: "CoinCategoryMap", columns: new[] { "CoinID", "CategoryID" }, unique: true); migrationBuilder.CreateIndex( name: "IX_CoinMarket_CoinID_Market", table: "CoinMarket", columns: new[] { "CoinID", "Market" }, unique: true); migrationBuilder.CreateIndex( name: "IX_CoinMarket_Market", table: "CoinMarket", column: "Market"); migrationBuilder.AddForeignKey( name: "FK_Board_Coin_CoinID", table: "Board", column: "CoinID", principalTable: "Coin", principalColumn: "ID", onDelete: ReferentialAction.SetNull); } } }