| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb
- {
- /// <inheritdoc />
- public partial class AddApiPurchase : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AddColumn<decimal>(
- name: "ApiCommissionRate",
- table: "Game",
- type: "decimal(18,2)",
- nullable: false,
- defaultValue: 0m);
- migrationBuilder.CreateTable(
- name: "ApiPurchase",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ApplicationID = table.Column<int>(type: "int", nullable: false),
- ChannelID = table.Column<int>(type: "int", nullable: false),
- CreditedMemberID = table.Column<int>(type: "int", nullable: false),
- GameID = table.Column<int>(type: "int", nullable: false),
- OrderID = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
- Marketplace = table.Column<int>(type: "int", nullable: false),
- ProductID = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
- SubID = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
- OrderPrice = table.Column<int>(type: "int", nullable: false),
- CommissionRate = table.Column<decimal>(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false),
- CommissionAmount = table.Column<int>(type: "int", nullable: false),
- CatalogPrice = table.Column<int>(type: "int", nullable: true),
- PriceMismatched = table.Column<bool>(type: "bit", nullable: false),
- Status = table.Column<int>(type: "int", nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
- ConfirmDueAt = table.Column<DateTime>(type: "datetime2", nullable: false),
- ConfirmedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
- CanceledAt = table.Column<DateTime>(type: "datetime2", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiPurchase", x => x.ID);
- table.ForeignKey(
- name: "FK_ApiPurchase_ApiApplication_ApplicationID",
- column: x => x.ApplicationID,
- principalTable: "ApiApplication",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- table.ForeignKey(
- name: "FK_ApiPurchase_Channel_ChannelID",
- column: x => x.ChannelID,
- principalTable: "Channel",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- table.ForeignKey(
- name: "FK_ApiPurchase_Game_GameID",
- column: x => x.GameID,
- principalTable: "Game",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- },
- comment: "게임사 API 결제 보고 원장 (채널 판매 수수료, 14일 보류 후 확정)");
- migrationBuilder.CreateTable(
- name: "GameProductCatalog",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- GameID = table.Column<int>(type: "int", nullable: false),
- ProductID = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
- Price = table.Column<int>(type: "int", nullable: false),
- IsActive = table.Column<bool>(type: "bit", nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
- UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_GameProductCatalog", x => x.ID);
- table.ForeignKey(
- name: "FK_GameProductCatalog_Game_GameID",
- column: x => x.GameID,
- principalTable: "Game",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "게임별 인앱 상품 SKU 정가 카탈로그 (API 결제 보고가 검증용)");
- migrationBuilder.CreateTable(
- name: "ApiPurchaseCancel",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- PurchaseID = table.Column<int>(type: "int", nullable: false),
- ApplicationID = table.Column<int>(type: "int", nullable: false),
- ChannelID = table.Column<int>(type: "int", nullable: false),
- CreditedMemberID = table.Column<int>(type: "int", nullable: false),
- WasConfirmed = table.Column<bool>(type: "bit", nullable: false),
- RecoveredAmount = table.Column<int>(type: "int", nullable: false),
- ShortfallAmount = table.Column<int>(type: "int", nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiPurchaseCancel", x => x.ID);
- table.ForeignKey(
- name: "FK_ApiPurchaseCancel_ApiPurchase_PurchaseID",
- column: x => x.PurchaseID,
- principalTable: "ApiPurchase",
- principalColumn: "ID",
- onDelete: ReferentialAction.Restrict);
- },
- comment: "API 결제 취소 감사 기록 (1 결제 1 취소)");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchase_ApplicationID_Marketplace_OrderID",
- table: "ApiPurchase",
- columns: new[] { "ApplicationID", "Marketplace", "OrderID" },
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchase_ChannelID",
- table: "ApiPurchase",
- column: "ChannelID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchase_CreatedAt",
- table: "ApiPurchase",
- column: "CreatedAt");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchase_GameID",
- table: "ApiPurchase",
- column: "GameID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchase_Status_ConfirmDueAt",
- table: "ApiPurchase",
- columns: new[] { "Status", "ConfirmDueAt" });
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchaseCancel_ApplicationID",
- table: "ApiPurchaseCancel",
- column: "ApplicationID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchaseCancel_ChannelID",
- table: "ApiPurchaseCancel",
- column: "ChannelID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchaseCancel_CreatedAt",
- table: "ApiPurchaseCancel",
- column: "CreatedAt");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPurchaseCancel_PurchaseID",
- table: "ApiPurchaseCancel",
- column: "PurchaseID",
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_GameProductCatalog_GameID_ProductID",
- table: "GameProductCatalog",
- columns: new[] { "GameID", "ProductID" },
- unique: true);
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ApiPurchaseCancel");
- migrationBuilder.DropTable(
- name: "GameProductCatalog");
- migrationBuilder.DropTable(
- name: "ApiPurchase");
- migrationBuilder.DropColumn(
- name: "ApiCommissionRate",
- table: "Game");
- }
- }
- }
|