blob: a16fcf4da25056644be5006ff57ac111e648a9ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
using Microsoft.EntityFrameworkCore.Migrations;
using System.Security.Cryptography;
namespace Timeline.Migrations
{
public static class JwtTokenGenerateHelper
{
public static byte[] GenerateKey()
{
using var random = RandomNumberGenerator.Create();
var key = new byte[16];
random.GetBytes(key);
return key;
}
}
public partial class AddJwtToken : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "jwt_token",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
key = table.Column<byte[]>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_jwt_token", x => x.id);
});
migrationBuilder.InsertData("jwt_token", "key", JwtTokenGenerateHelper.GenerateKey());
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "jwt_token");
}
}
}
|