From 2e86ace4593d32a2cb1a4be9a758911ff25e4a89 Mon Sep 17 00:00:00 2001 From: Paweł Bernaciak Date: Wed, 25 Oct 2023 20:28:34 +0200 Subject: Model fixes --- .../20231024192803_Add creation dates.cs | 201 +++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs (limited to 'backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs') diff --git a/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs b/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs new file mode 100644 index 0000000..3612108 --- /dev/null +++ b/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs @@ -0,0 +1,201 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elements.Data.Migrations +{ + /// + public partial class Addcreationdates : Migration + { + /// + 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( + name: "CreationDate", + table: "Suggestions", + type: "TEXT", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + 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); + } + + /// + 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); + } + } +} -- cgit v1.2.3