From 3d6c9fd916e18c99b3a5497b8313672680571b5e Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 9 Mar 2022 21:21:15 +0800 Subject: Add user token entity in preparation for refactor of tokens. --- .../Migrations/20220309132001_AddUserTokenTable.cs | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs (limited to 'BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs') diff --git a/BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs b/BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs new file mode 100644 index 00000000..02cb5a14 --- /dev/null +++ b/BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs @@ -0,0 +1,52 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Timeline.Migrations +{ + public partial class AddUserTokenTable : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "user_token", + columns: table => new + { + id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + user_id = table.Column(type: "INTEGER", nullable: false), + token = table.Column(type: "TEXT", nullable: false), + expire_at = table.Column(type: "TEXT", nullable: true), + create_at = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_user_token", x => x.id); + table.ForeignKey( + name: "FK_user_token_users_user_id", + column: x => x.user_id, + principalTable: "users", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_user_token_token", + table: "user_token", + column: "token", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_user_token_user_id", + table: "user_token", + column: "user_id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "user_token"); + } + } +} -- cgit v1.2.3