using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
///
public partial class RefreshSessions : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RefreshSessions",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false),
UserId = table.Column(type: "char(36)", nullable: false),
TokenHash = table.Column(type: "varchar(64)", maxLength: 64, nullable: false),
ClientType = table.Column(type: "varchar(20)", maxLength: 20, nullable: false),
SecurityStamp = table.Column(type: "varchar(100)", maxLength: 100, nullable: false),
ExpiresAt = table.Column(type: "datetime(6)", nullable: false),
CreatedAt = table.Column(type: "datetime(6)", nullable: false),
LastRefreshedAt = table.Column(type: "datetime(6)", nullable: false),
RevokedAt = table.Column(type: "datetime(6)", nullable: true),
ReplacedBySessionId = table.Column(type: "char(36)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RefreshSessions", x => x.Id);
table.ForeignKey(
name: "FK_RefreshSessions_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_RefreshSessions_TokenHash",
table: "RefreshSessions",
column: "TokenHash",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RefreshSessions_UserId_ExpiresAt",
table: "RefreshSessions",
columns: new[] { "UserId", "ExpiresAt" });
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RefreshSessions");
}
}
}