56 lines
2.2 KiB
C#
56 lines
2.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace VigilCareClinicalAPI.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddRefreshTokens : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "refresh_tokens",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
|
|
token = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
user_id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
expires_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"),
|
|
revoked_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_refresh_tokens", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_refresh_tokens_clinical_users_user_id",
|
|
column: x => x.user_id,
|
|
principalTable: "clinical_users",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_refresh_tokens_token",
|
|
table: "refresh_tokens",
|
|
column: "token",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_refresh_tokens_user_id",
|
|
table: "refresh_tokens",
|
|
column: "user_id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "refresh_tokens");
|
|
}
|
|
}
|
|
}
|