aboutsummaryrefslogtreecommitdiff
path: root/Migrations/20241106012338_Bart.cs
blob: 8174579aa28d3bb3d11d979bcc2d20c35db66124 (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
85
86
87
88
89
90
91
92
93
94
95
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace PagerParser.Migrations
{
    /// <inheritdoc />
    public partial class Bart : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "BartMembers",
                columns: table => new
                {
                    BartMemberId = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    MemberName = table.Column<string>(type: "text", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BartMembers", x => x.BartMemberId);
                });

            migrationBuilder.CreateTable(
                name: "BartAvailabilityRecords",
                columns: table => new
                {
                    BartAvailabilityRecordId = table.Column<int>(type: "integer", nullable: false)
                        .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
                    Timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    MemberBartMemberId = table.Column<int>(type: "integer", nullable: false),
                    Status = table.Column<int>(type: "integer", nullable: false),
                    IsDefault = table.Column<bool>(type: "boolean", nullable: false),
                    ModifiedOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    ModifiedByBartMemberId = table.Column<int>(type: "integer", nullable: true),
                    CreatedOn = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    CreatedByBartMemberId = table.Column<int>(type: "integer", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_BartAvailabilityRecords", x => x.BartAvailabilityRecordId);
                    table.ForeignKey(
                        name: "FK_BartAvailabilityRecords_BartMembers_CreatedByBartMemberId",
                        column: x => x.CreatedByBartMemberId,
                        principalTable: "BartMembers",
                        principalColumn: "BartMemberId");
                    table.ForeignKey(
                        name: "FK_BartAvailabilityRecords_BartMembers_MemberBartMemberId",
                        column: x => x.MemberBartMemberId,
                        principalTable: "BartMembers",
                        principalColumn: "BartMemberId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_BartAvailabilityRecords_BartMembers_ModifiedByBartMemberId",
                        column: x => x.ModifiedByBartMemberId,
                        principalTable: "BartMembers",
                        principalColumn: "BartMemberId");
                });

            migrationBuilder.CreateIndex(
                name: "IX_BartAvailabilityRecords_CreatedByBartMemberId",
                table: "BartAvailabilityRecords",
                column: "CreatedByBartMemberId");

            migrationBuilder.CreateIndex(
                name: "IX_BartAvailabilityRecords_MemberBartMemberId",
                table: "BartAvailabilityRecords",
                column: "MemberBartMemberId");

            migrationBuilder.CreateIndex(
                name: "IX_BartAvailabilityRecords_ModifiedByBartMemberId",
                table: "BartAvailabilityRecords",
                column: "ModifiedByBartMemberId");

            migrationBuilder.CreateIndex(
                name: "IX_BartMembers_MemberName",
                table: "BartMembers",
                column: "MemberName");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "BartAvailabilityRecords");

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