source: iknow-api/Migrations/20251028091953_new.cs@ 1d32d5c

Last change on this file since 1d32d5c was 1e58098, checked in by imbrsk <boris696boris@…>, 11 months ago

added remaining methods to refreshtoken feature

  • Property mode set to 100644
File size: 3.1 KB
Line 
1using System;
2using Microsoft.EntityFrameworkCore.Migrations;
3using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
4
5#nullable disable
6
7namespace iknow_api.Migrations
8{
9 /// <inheritdoc />
10 public partial class @new : Migration
11 {
12 /// <inheritdoc />
13 protected override void Up(MigrationBuilder migrationBuilder)
14 {
15 migrationBuilder.CreateTable(
16 name: "User",
17 columns: table => new
18 {
19 Id = table.Column<int>(type: "integer", nullable: false)
20 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
21 Name = table.Column<string>(type: "text", nullable: true),
22 Surname = table.Column<string>(type: "text", nullable: true),
23 Index = table.Column<string>(type: "text", nullable: true),
24 Email = table.Column<string>(type: "text", nullable: true),
25 PasswordHash = table.Column<string>(type: "text", nullable: true),
26 Bday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
27 CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
28 Role = table.Column<int>(type: "integer", nullable: false)
29 },
30 constraints: table =>
31 {
32 table.PrimaryKey("PK_User", x => x.Id);
33 });
34
35 migrationBuilder.CreateTable(
36 name: "RefreshToken",
37 columns: table => new
38 {
39 Id = table.Column<int>(type: "integer", nullable: false)
40 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
41 UserId = table.Column<int>(type: "integer", nullable: false),
42 Token = table.Column<string>(type: "text", nullable: false),
43 ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
44 IsValid = table.Column<bool>(type: "boolean", nullable: false)
45 },
46 constraints: table =>
47 {
48 table.PrimaryKey("PK_RefreshToken", x => x.Id);
49 table.ForeignKey(
50 name: "FK_RefreshToken_User_UserId",
51 column: x => x.UserId,
52 principalTable: "User",
53 principalColumn: "Id",
54 onDelete: ReferentialAction.Cascade);
55 });
56
57 migrationBuilder.CreateIndex(
58 name: "IX_RefreshToken_UserId",
59 table: "RefreshToken",
60 column: "UserId");
61 }
62
63 /// <inheritdoc />
64 protected override void Down(MigrationBuilder migrationBuilder)
65 {
66 migrationBuilder.DropTable(
67 name: "RefreshToken");
68
69 migrationBuilder.DropTable(
70 name: "User");
71 }
72 }
73}
Note: See TracBrowser for help on using the repository browser.