275 lines
9.9 KiB
C#
275 lines
9.9 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace API.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class RecipeModelAdded : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "UserName",
|
|
table: "Users",
|
|
type: "TEXT",
|
|
nullable: false,
|
|
oldClrType: typeof(string),
|
|
oldType: "longtext");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Salt",
|
|
table: "Users",
|
|
type: "TEXT",
|
|
nullable: true,
|
|
oldClrType: typeof(string),
|
|
oldType: "longtext",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<DateTime>(
|
|
name: "RefreshTokenExpireAt",
|
|
table: "Users",
|
|
type: "TEXT",
|
|
nullable: false,
|
|
oldClrType: typeof(DateTime),
|
|
oldType: "datetime(6)");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "RefreshToken",
|
|
table: "Users",
|
|
type: "TEXT",
|
|
nullable: true,
|
|
oldClrType: typeof(string),
|
|
oldType: "longtext",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Password",
|
|
table: "Users",
|
|
type: "TEXT",
|
|
nullable: false,
|
|
oldClrType: typeof(string),
|
|
oldType: "longtext");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Email",
|
|
table: "Users",
|
|
type: "TEXT",
|
|
nullable: false,
|
|
oldClrType: typeof(string),
|
|
oldType: "longtext");
|
|
|
|
migrationBuilder.AlterColumn<int>(
|
|
name: "Id",
|
|
table: "Users",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
oldClrType: typeof(int),
|
|
oldType: "int")
|
|
.Annotation("Sqlite:Autoincrement", true)
|
|
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "PrefereredRecipesId",
|
|
table: "Users",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PrefereredRecipes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PrefereredRecipes", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ShoppingList",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Amount = table.Column<double>(type: "REAL", nullable: false),
|
|
Unit = table.Column<string>(type: "TEXT", nullable: false),
|
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
|
Checked = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
UserId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ShoppingList", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingList_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Recipes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Name = table.Column<string>(type: "TEXT", nullable: false),
|
|
Description = table.Column<string>(type: "TEXT", nullable: false),
|
|
Directions = table.Column<string>(type: "TEXT", nullable: false),
|
|
PrefereredRecipesId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Recipes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Recipes_PrefereredRecipes_PrefereredRecipesId",
|
|
column: x => x.PrefereredRecipesId,
|
|
principalTable: "PrefereredRecipes",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Ingredient",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Amount = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Unit = table.Column<string>(type: "TEXT", nullable: false),
|
|
Element = table.Column<string>(type: "TEXT", nullable: false),
|
|
RecipeId = table.Column<int>(type: "INTEGER", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Ingredient", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Ingredient_Recipes_RecipeId",
|
|
column: x => x.RecipeId,
|
|
principalTable: "Recipes",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Users_PrefereredRecipesId",
|
|
table: "Users",
|
|
column: "PrefereredRecipesId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Ingredient_RecipeId",
|
|
table: "Ingredient",
|
|
column: "RecipeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Recipes_PrefereredRecipesId",
|
|
table: "Recipes",
|
|
column: "PrefereredRecipesId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingList_UserId",
|
|
table: "ShoppingList",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Users_PrefereredRecipes_PrefereredRecipesId",
|
|
table: "Users",
|
|
column: "PrefereredRecipesId",
|
|
principalTable: "PrefereredRecipes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Users_PrefereredRecipes_PrefereredRecipesId",
|
|
table: "Users");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Ingredient");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ShoppingList");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Recipes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PrefereredRecipes");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Users_PrefereredRecipesId",
|
|
table: "Users");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "PrefereredRecipesId",
|
|
table: "Users");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "UserName",
|
|
table: "Users",
|
|
type: "longtext",
|
|
nullable: false,
|
|
oldClrType: typeof(string),
|
|
oldType: "TEXT");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Salt",
|
|
table: "Users",
|
|
type: "longtext",
|
|
nullable: true,
|
|
oldClrType: typeof(string),
|
|
oldType: "TEXT",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<DateTime>(
|
|
name: "RefreshTokenExpireAt",
|
|
table: "Users",
|
|
type: "datetime(6)",
|
|
nullable: false,
|
|
oldClrType: typeof(DateTime),
|
|
oldType: "TEXT");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "RefreshToken",
|
|
table: "Users",
|
|
type: "longtext",
|
|
nullable: true,
|
|
oldClrType: typeof(string),
|
|
oldType: "TEXT",
|
|
oldNullable: true);
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Password",
|
|
table: "Users",
|
|
type: "longtext",
|
|
nullable: false,
|
|
oldClrType: typeof(string),
|
|
oldType: "TEXT");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Email",
|
|
table: "Users",
|
|
type: "longtext",
|
|
nullable: false,
|
|
oldClrType: typeof(string),
|
|
oldType: "TEXT");
|
|
|
|
migrationBuilder.AlterColumn<int>(
|
|
name: "Id",
|
|
table: "Users",
|
|
type: "int",
|
|
nullable: false,
|
|
oldClrType: typeof(int),
|
|
oldType: "INTEGER")
|
|
.Annotation("Sqlite:Autoincrement", true)
|
|
.OldAnnotation("Sqlite:Autoincrement", true);
|
|
}
|
|
}
|
|
}
|