aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Migrations/20201217093401_AddHighlightTimelines.cs
blob: e838615e4a6a2671f4e730efc9635b0c14569eb2 (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
using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Timeline.Migrations
{
    public partial class AddHighlightTimelines : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "highlight_timelines",
                columns: table => new
                {
                    id = table.Column<long>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    timeline_id = table.Column<long>(type: "INTEGER", nullable: false),
                    operator_id = table.Column<long>(type: "INTEGER", nullable: true),
                    add_time = table.Column<DateTime>(type: "TEXT", nullable: false),
                    order = table.Column<long>(type: "INTEGER", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_highlight_timelines", x => x.id);
                    table.ForeignKey(
                        name: "FK_highlight_timelines_timelines_timeline_id",
                        column: x => x.timeline_id,
                        principalTable: "timelines",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_highlight_timelines_users_operator_id",
                        column: x => x.operator_id,
                        principalTable: "users",
                        principalColumn: "id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_highlight_timelines_operator_id",
                table: "highlight_timelines",
                column: "operator_id");

            migrationBuilder.CreateIndex(
                name: "IX_highlight_timelines_timeline_id",
                table: "highlight_timelines",
                column: "timeline_id");
        }

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