| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using Microsoft.EntityFrameworkCore.Migrations;
- #nullable disable
- namespace Infrastructure.Migrations.AppDb
- {
- /// <inheritdoc />
- public partial class AddEmailLogQueue : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "EmailLog",
- columns: table => new
- {
- ID = table.Column<long>(type: "bigint", nullable: false, comment: "PK")
- .Annotation("SqlServer:Identity", "1, 1"),
- ToAddress = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false, comment: "수신자 이메일"),
- Subject = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false, comment: "제목"),
- MessageHtml = table.Column<string>(type: "nvarchar(max)", nullable: false, comment: "HTML 본문"),
- MessageText = table.Column<string>(type: "nvarchar(max)", nullable: true, comment: "텍스트 본문 (선택)"),
- Status = table.Column<byte>(type: "tinyint", nullable: false, defaultValue: (byte)0, comment: "상태 (0=Pending, 1=Processing, 2=Sent, 3=Failed)"),
- RetryCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0, comment: "재시도 횟수"),
- MaxRetryCount = table.Column<int>(type: "int", nullable: false, defaultValue: 3, comment: "최대 재시도 횟수"),
- NextRetryAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()", comment: "다음 시도 시각 (UTC)"),
- LastError = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true, comment: "마지막 오류 메시지"),
- Category = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "카테고리 (auth.register, forum.post.notify 등)"),
- CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()", comment: "등록 시각 (UTC)"),
- ProcessedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "처리 완료 시각 (UTC)"),
- FailedAt = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "실패 확정 시각 (UTC)")
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_EmailLog", x => x.ID);
- },
- comment: "이메일 발송 큐");
- migrationBuilder.CreateIndex(
- name: "IX_EmailLog_CreatedAt",
- table: "EmailLog",
- column: "CreatedAt");
- migrationBuilder.CreateIndex(
- name: "IX_EmailLog_Status_NextRetryAt",
- table: "EmailLog",
- columns: new[] { "Status", "NextRetryAt" });
- }
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "EmailLog");
- }
- }
- }
|