aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Migrations/20221114034213_RemoveTimeTracker.cs
blob: 70b2539c0b75222685c45405bc1b75148e220e14 (plain) (blame)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace IOL.GreatOffice.Api.Migrations
{
    /// <inheritdoc />
    public partial class RemoveTimeTracker : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "time_labels");

            migrationBuilder.DropTable(
                name: "time_entries");

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

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "time_categories",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    tenantid = table.Column<Guid>(name: "tenant_id", type: "uuid", nullable: true),
                    userid = table.Column<Guid>(name: "user_id", type: "uuid", nullable: true),
                    color = table.Column<string>(type: "text", nullable: true),
                    createdat = table.Column<DateTime>(name: "created_at", type: "timestamp with time zone", nullable: false),
                    createdby = table.Column<Guid>(name: "created_by", type: "uuid", nullable: true),
                    deleted = table.Column<bool>(type: "boolean", nullable: false),
                    deletedat = table.Column<DateTime>(name: "deleted_at", type: "timestamp with time zone", nullable: true),
                    deletedby = table.Column<Guid>(name: "deleted_by", type: "uuid", nullable: true),
                    modifiedat = table.Column<DateTime>(name: "modified_at", type: "timestamp with time zone", nullable: true),
                    modifiedby = table.Column<Guid>(name: "modified_by", type: "uuid", nullable: true),
                    name = table.Column<string>(type: "text", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_time_categories", x => x.id);
                    table.ForeignKey(
                        name: "fk_time_categories_tenants_tenant_id",
                        column: x => x.tenantid,
                        principalTable: "tenants",
                        principalColumn: "id");
                    table.ForeignKey(
                        name: "fk_time_categories_users_user_id",
                        column: x => x.userid,
                        principalTable: "users",
                        principalColumn: "id");
                });

            migrationBuilder.CreateTable(
                name: "time_entries",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    categoryid = table.Column<Guid>(name: "category_id", type: "uuid", nullable: true),
                    tenantid = table.Column<Guid>(name: "tenant_id", type: "uuid", nullable: true),
                    userid = table.Column<Guid>(name: "user_id", type: "uuid", nullable: true),
                    createdat = table.Column<DateTime>(name: "created_at", type: "timestamp with time zone", nullable: false),
                    createdby = table.Column<Guid>(name: "created_by", type: "uuid", nullable: true),
                    deleted = table.Column<bool>(type: "boolean", nullable: false),
                    deletedat = table.Column<DateTime>(name: "deleted_at", type: "timestamp with time zone", nullable: true),
                    deletedby = table.Column<Guid>(name: "deleted_by", type: "uuid", nullable: true),
                    description = table.Column<string>(type: "text", nullable: true),
                    modifiedat = table.Column<DateTime>(name: "modified_at", type: "timestamp with time zone", nullable: true),
                    modifiedby = table.Column<Guid>(name: "modified_by", type: "uuid", nullable: true),
                    start = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    stop = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_time_entries", x => x.id);
                    table.ForeignKey(
                        name: "fk_time_entries_tenants_tenant_id",
                        column: x => x.tenantid,
                        principalTable: "tenants",
                        principalColumn: "id");
                    table.ForeignKey(
                        name: "fk_time_entries_time_categories_category_id",
                        column: x => x.categoryid,
                        principalTable: "time_categories",
                        principalColumn: "id");
                    table.ForeignKey(
                        name: "fk_time_entries_users_user_id",
                        column: x => x.userid,
                        principalTable: "users",
                        principalColumn: "id");
                });

            migrationBuilder.CreateTable(
                name: "time_labels",
                columns: table => new
                {
                    id = table.Column<Guid>(type: "uuid", nullable: false),
                    tenantid = table.Column<Guid>(name: "tenant_id", type: "uuid", nullable: true),
                    userid = table.Column<Guid>(name: "user_id", type: "uuid", nullable: true),
                    color = table.Column<string>(type: "text", nullable: true),
                    createdat = table.Column<DateTime>(name: "created_at", type: "timestamp with time zone", nullable: false),
                    createdby = table.Column<Guid>(name: "created_by", type: "uuid", nullable: true),
                    deleted = table.Column<bool>(type: "boolean", nullable: false),
                    deletedat = table.Column<DateTime>(name: "deleted_at", type: "timestamp with time zone", nullable: true),
                    deletedby = table.Column<Guid>(name: "deleted_by", type: "uuid", nullable: true),
                    modifiedat = table.Column<DateTime>(name: "modified_at", type: "timestamp with time zone", nullable: true),
                    modifiedby = table.Column<Guid>(name: "modified_by", type: "uuid", nullable: true),
                    name = table.Column<string>(type: "text", nullable: true),
                    timeentryid = table.Column<Guid>(name: "time_entry_id", type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("pk_time_labels", x => x.id);
                    table.ForeignKey(
                        name: "fk_time_labels_tenants_tenant_id",
                        column: x => x.tenantid,
                        principalTable: "tenants",
                        principalColumn: "id");
                    table.ForeignKey(
                        name: "fk_time_labels_time_entries_time_entry_id",
                        column: x => x.timeentryid,
                        principalTable: "time_entries",
                        principalColumn: "id");
                    table.ForeignKey(
                        name: "fk_time_labels_users_user_id",
                        column: x => x.userid,
                        principalTable: "users",
                        principalColumn: "id");
                });

            migrationBuilder.CreateIndex(
                name: "ix_time_categories_tenant_id",
                table: "time_categories",
                column: "tenant_id");

            migrationBuilder.CreateIndex(
                name: "ix_time_categories_user_id",
                table: "time_categories",
                column: "user_id");

            migrationBuilder.CreateIndex(
                name: "ix_time_entries_category_id",
                table: "time_entries",
                column: "category_id");

            migrationBuilder.CreateIndex(
                name: "ix_time_entries_tenant_id",
                table: "time_entries",
                column: "tenant_id");

            migrationBuilder.CreateIndex(
                name: "ix_time_entries_user_id",
                table: "time_entries",
                column: "user_id");

            migrationBuilder.CreateIndex(
                name: "ix_time_labels_tenant_id",
                table: "time_labels",
                column: "tenant_id");

            migrationBuilder.CreateIndex(
                name: "ix_time_labels_time_entry_id",
                table: "time_labels",
                column: "time_entry_id");

            migrationBuilder.CreateIndex(
                name: "ix_time_labels_user_id",
                table: "time_labels",
                column: "user_id");
        }
    }
}