aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Migrations/20220417152839_AddRegisterCode.cs
blob: c76cb4d0f6536257753941a0d88f89027dde42fb (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Timeline.Migrations
{
    public partial class AddRegisterCode : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "register_code",
                columns: table => new
                {
                    id = table.Column<long>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    owner_id = table.Column<long>(type: "INTEGER", nullable: true),
                    code = table.Column<string>(type: "TEXT", nullable: false),
                    enabled = table.Column<bool>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_register_code", x => x.id);
                    table.ForeignKey(
                        name: "FK_register_code_users_owner_id",
                        column: x => x.owner_id,
                        principalTable: "users",
                        principalColumn: "id");
                });

            migrationBuilder.CreateTable(
                name: "user_register_info",
                columns: table => new
                {
                    id = table.Column<long>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    user_id = table.Column<long>(type: "INTEGER", nullable: false),
                    register_code = table.Column<string>(type: "TEXT", nullable: false),
                    introducer_id = table.Column<long>(type: "INTEGER", nullable: true),
                    register_time = table.Column<DateTime>(type: "TEXT", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_user_register_info", x => x.id);
                    table.ForeignKey(
                        name: "FK_user_register_info_users_introducer_id",
                        column: x => x.introducer_id,
                        principalTable: "users",
                        principalColumn: "id");
                    table.ForeignKey(
                        name: "FK_user_register_info_users_user_id",
                        column: x => x.user_id,
                        principalTable: "users",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_register_code_owner_id",
                table: "register_code",
                column: "owner_id");

            migrationBuilder.CreateIndex(
                name: "IX_user_register_info_introducer_id",
                table: "user_register_info",
                column: "introducer_id");

            migrationBuilder.CreateIndex(
                name: "IX_user_register_info_user_id",
                table: "user_register_info",
                column: "user_id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "register_code");

            migrationBuilder.DropTable(
                name: "user_register_info");
        }
    }
}