| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb
- {
- /// <inheritdoc />
- public partial class AddDeveloperPortalSchema : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn<int>(
- name: "Price",
- table: "Product",
- type: "int",
- nullable: false,
- comment: "판매가 (KRW)",
- oldClrType: typeof(int),
- oldType: "int",
- oldComment: "정가 (P)");
- migrationBuilder.AlterColumn<int>(
- name: "DiscountValue",
- table: "Product",
- type: "int",
- nullable: false,
- oldClrType: typeof(int),
- oldType: "int",
- oldComment: "할인 값 (Percent: 0..99, Amount: 0..Price)");
- migrationBuilder.AlterColumn<byte>(
- name: "DiscountType",
- table: "Product",
- type: "tinyint",
- nullable: false,
- oldClrType: typeof(byte),
- oldType: "tinyint",
- oldComment: "할인 모드 (0=None, 1=Percent, 2=Amount)");
- migrationBuilder.CreateTable(
- name: "ApiApplication",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- OwnerMemberID = table.Column<int>(type: "int", nullable: false),
- Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
- Description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
- HomepageUrl = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
- LogoPath = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
- Status = table.Column<int>(type: "int", nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
- UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
- ApprovedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
- SuspendedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiApplication", x => x.ID);
- table.ForeignKey(
- name: "FK_ApiApplication_Member_OwnerMemberID",
- column: x => x.OwnerMemberID,
- principalTable: "Member",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "개발자 API 앱");
- migrationBuilder.CreateTable(
- name: "ApiPersonalAccessToken",
- columns: table => new
- {
- ID = table.Column<long>(type: "bigint", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- OwnerMemberID = table.Column<int>(type: "int", nullable: false),
- Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
- TokenHash = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
- TokenHint = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: false),
- ScopesCsv = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
- ExpiresAt = table.Column<DateTime>(type: "datetime2", nullable: true),
- LastUsedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
- RevokedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiPersonalAccessToken", x => x.ID);
- table.ForeignKey(
- name: "FK_ApiPersonalAccessToken_Member_OwnerMemberID",
- column: x => x.OwnerMemberID,
- principalTable: "Member",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "Personal Access Token (PAT)");
- migrationBuilder.CreateTable(
- name: "ApiRequestLog",
- columns: table => new
- {
- ID = table.Column<long>(type: "bigint", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ApplicationID = table.Column<int>(type: "int", nullable: true),
- PatID = table.Column<long>(type: "bigint", nullable: true),
- Endpoint = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
- Method = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
- StatusCode = table.Column<int>(type: "int", nullable: false),
- ResponseMs = table.Column<int>(type: "int", nullable: false),
- IpAddress = table.Column<string>(type: "nvarchar(45)", maxLength: 45, nullable: true),
- RequestedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiRequestLog", x => x.ID);
- },
- comment: "공개 API 호출 로그");
- migrationBuilder.CreateTable(
- name: "ApiApplicationScope",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ApplicationID = table.Column<int>(type: "int", nullable: false),
- Scope = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiApplicationScope", x => x.ID);
- table.ForeignKey(
- name: "FK_ApiApplicationScope_ApiApplication_ApplicationID",
- column: x => x.ApplicationID,
- principalTable: "ApiApplication",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "앱이 요청한 scope 목록");
- migrationBuilder.CreateTable(
- name: "ApiCredential",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ApplicationID = table.Column<int>(type: "int", nullable: false),
- ClientID = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
- SecretHash = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
- SecretHint = table.Column<string>(type: "nvarchar(4)", maxLength: 4, nullable: false),
- Status = table.Column<int>(type: "int", nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
- LastUsedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
- RevokedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiCredential", x => x.ID);
- table.ForeignKey(
- name: "FK_ApiCredential_ApiApplication_ApplicationID",
- column: x => x.ApplicationID,
- principalTable: "ApiApplication",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "OAuth2 Client Credentials");
- migrationBuilder.CreateTable(
- name: "ApiRateLimit",
- columns: table => new
- {
- ID = table.Column<int>(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- ApplicationID = table.Column<int>(type: "int", nullable: false),
- LimitPerMinute = table.Column<int>(type: "int", nullable: false),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
- UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ApiRateLimit", x => x.ID);
- table.ForeignKey(
- name: "FK_ApiRateLimit_ApiApplication_ApplicationID",
- column: x => x.ApplicationID,
- principalTable: "ApiApplication",
- principalColumn: "ID",
- onDelete: ReferentialAction.Cascade);
- },
- comment: "앱별 Rate Limit override");
- migrationBuilder.CreateIndex(
- name: "IX_ApiApplication_OwnerMemberID",
- table: "ApiApplication",
- column: "OwnerMemberID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiApplication_Status",
- table: "ApiApplication",
- column: "Status");
- migrationBuilder.CreateIndex(
- name: "IX_ApiApplicationScope_ApplicationID_Scope",
- table: "ApiApplicationScope",
- columns: new[] { "ApplicationID", "Scope" },
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_ApiCredential_ApplicationID",
- table: "ApiCredential",
- column: "ApplicationID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiCredential_ClientID",
- table: "ApiCredential",
- column: "ClientID",
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_ApiPersonalAccessToken_OwnerMemberID",
- table: "ApiPersonalAccessToken",
- column: "OwnerMemberID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiPersonalAccessToken_TokenHash",
- table: "ApiPersonalAccessToken",
- column: "TokenHash",
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_ApiRateLimit_ApplicationID",
- table: "ApiRateLimit",
- column: "ApplicationID",
- unique: true);
- migrationBuilder.CreateIndex(
- name: "IX_ApiRequestLog_ApplicationID",
- table: "ApiRequestLog",
- column: "ApplicationID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiRequestLog_PatID",
- table: "ApiRequestLog",
- column: "PatID");
- migrationBuilder.CreateIndex(
- name: "IX_ApiRequestLog_RequestedAt",
- table: "ApiRequestLog",
- column: "RequestedAt");
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ApiApplicationScope");
- migrationBuilder.DropTable(
- name: "ApiCredential");
- migrationBuilder.DropTable(
- name: "ApiPersonalAccessToken");
- migrationBuilder.DropTable(
- name: "ApiRateLimit");
- migrationBuilder.DropTable(
- name: "ApiRequestLog");
- migrationBuilder.DropTable(
- name: "ApiApplication");
- migrationBuilder.AlterColumn<int>(
- name: "Price",
- table: "Product",
- type: "int",
- nullable: false,
- comment: "정가 (P)",
- oldClrType: typeof(int),
- oldType: "int",
- oldComment: "판매가 (KRW)");
- migrationBuilder.AlterColumn<int>(
- name: "DiscountValue",
- table: "Product",
- type: "int",
- nullable: false,
- comment: "할인 값 (Percent: 0..99, Amount: 0..Price)",
- oldClrType: typeof(int),
- oldType: "int");
- migrationBuilder.AlterColumn<byte>(
- name: "DiscountType",
- table: "Product",
- type: "tinyint",
- nullable: false,
- comment: "할인 모드 (0=None, 1=Percent, 2=Amount)",
- oldClrType: typeof(byte),
- oldType: "tinyint");
- }
- }
- }
|