summaryrefslogtreecommitdiff
path: root/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs
blob: 36121089f65cccd408fe8ab9cb76725ef310f4c5 (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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Elements.Data.Migrations
{
    /// <inheritdoc />
    public partial class Addcreationdates : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Recipes_Elements_FirstIngredientId",
                table: "Recipes");

            migrationBuilder.DropForeignKey(
                name: "FK_Recipes_Elements_ResultId",
                table: "Recipes");

            migrationBuilder.DropForeignKey(
                name: "FK_Recipes_Elements_SecondIngredientId",
                table: "Recipes");

            migrationBuilder.RenameColumn(
                name: "SecondIngredientId",
                table: "Recipes",
                newName: "SecondElementId");

            migrationBuilder.RenameColumn(
                name: "ResultId",
                table: "Recipes",
                newName: "ResultElementId");

            migrationBuilder.RenameColumn(
                name: "FirstIngredientId",
                table: "Recipes",
                newName: "FirstElementId");

            migrationBuilder.RenameIndex(
                name: "IX_Recipes_SecondIngredientId",
                table: "Recipes",
                newName: "IX_Recipes_SecondElementId");

            migrationBuilder.RenameIndex(
                name: "IX_Recipes_ResultId",
                table: "Recipes",
                newName: "IX_Recipes_ResultElementId");

            migrationBuilder.RenameIndex(
                name: "IX_Recipes_FirstIngredientId",
                table: "Recipes",
                newName: "IX_Recipes_FirstElementId");

            migrationBuilder.AddColumn<DateTime>(
                name: "CreationDate",
                table: "Suggestions",
                type: "TEXT",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<DateTime>(
                name: "CreationDate",
                table: "Elements",
                type: "TEXT",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.UpdateData(
                table: "Elements",
                keyColumn: "Id",
                keyValue: 1,
                column: "CreationDate",
                value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(1750));

            migrationBuilder.UpdateData(
                table: "Elements",
                keyColumn: "Id",
                keyValue: 2,
                column: "CreationDate",
                value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(2880));

            migrationBuilder.UpdateData(
                table: "Elements",
                keyColumn: "Id",
                keyValue: 3,
                column: "CreationDate",
                value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3350));

            migrationBuilder.UpdateData(
                table: "Elements",
                keyColumn: "Id",
                keyValue: 4,
                column: "CreationDate",
                value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3790));

            migrationBuilder.AddForeignKey(
                name: "FK_Recipes_Elements_FirstElementId",
                table: "Recipes",
                column: "FirstElementId",
                principalTable: "Elements",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Recipes_Elements_ResultElementId",
                table: "Recipes",
                column: "ResultElementId",
                principalTable: "Elements",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Recipes_Elements_SecondElementId",
                table: "Recipes",
                column: "SecondElementId",
                principalTable: "Elements",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Recipes_Elements_FirstElementId",
                table: "Recipes");

            migrationBuilder.DropForeignKey(
                name: "FK_Recipes_Elements_ResultElementId",
                table: "Recipes");

            migrationBuilder.DropForeignKey(
                name: "FK_Recipes_Elements_SecondElementId",
                table: "Recipes");

            migrationBuilder.DropColumn(
                name: "CreationDate",
                table: "Suggestions");

            migrationBuilder.DropColumn(
                name: "CreationDate",
                table: "Elements");

            migrationBuilder.RenameColumn(
                name: "SecondElementId",
                table: "Recipes",
                newName: "SecondIngredientId");

            migrationBuilder.RenameColumn(
                name: "ResultElementId",
                table: "Recipes",
                newName: "ResultId");

            migrationBuilder.RenameColumn(
                name: "FirstElementId",
                table: "Recipes",
                newName: "FirstIngredientId");

            migrationBuilder.RenameIndex(
                name: "IX_Recipes_SecondElementId",
                table: "Recipes",
                newName: "IX_Recipes_SecondIngredientId");

            migrationBuilder.RenameIndex(
                name: "IX_Recipes_ResultElementId",
                table: "Recipes",
                newName: "IX_Recipes_ResultId");

            migrationBuilder.RenameIndex(
                name: "IX_Recipes_FirstElementId",
                table: "Recipes",
                newName: "IX_Recipes_FirstIngredientId");

            migrationBuilder.AddForeignKey(
                name: "FK_Recipes_Elements_FirstIngredientId",
                table: "Recipes",
                column: "FirstIngredientId",
                principalTable: "Elements",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Recipes_Elements_ResultId",
                table: "Recipes",
                column: "ResultId",
                principalTable: "Elements",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Recipes_Elements_SecondIngredientId",
                table: "Recipes",
                column: "SecondIngredientId",
                principalTable: "Elements",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}