diff options
author | crupest <crupest@outlook.com> | 2022-03-09 21:21:15 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-09 21:21:15 +0800 |
commit | 3d6c9fd916e18c99b3a5497b8313672680571b5e (patch) | |
tree | e67ae49937dcdb7f5c874a2ebfdca4fde72a059f /BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs | |
parent | 3cd0140ff4425b37b6e8dd8e8f16a54b1338c352 (diff) | |
download | timeline-3d6c9fd916e18c99b3a5497b8313672680571b5e.tar.gz timeline-3d6c9fd916e18c99b3a5497b8313672680571b5e.tar.bz2 timeline-3d6c9fd916e18c99b3a5497b8313672680571b5e.zip |
Add user token entity in preparation for refactor of tokens.
Diffstat (limited to 'BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs')
-rw-r--r-- | BackEnd/Timeline/Migrations/20220309132001_AddUserTokenTable.cs | 52 |
1 files changed, 52 insertions, 0 deletions
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<long>(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + user_id = table.Column<long>(type: "INTEGER", nullable: false), + token = table.Column<string>(type: "TEXT", nullable: false), + expire_at = table.Column<DateTime>(type: "TEXT", nullable: true), + create_at = table.Column<DateTime>(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"); + } + } +} |