Compare commits

...

2 Commits

Author SHA1 Message Date
Jeas0001
15de778225 Migrations 2025-04-29 13:56:41 +02:00
Jeas0001
792bf196f0 SQLite added to gitignore 2025-04-29 13:56:31 +02:00
6 changed files with 403 additions and 172 deletions

3
.gitignore vendored
View File

@ -6,3 +6,6 @@
/backend/API/appsettings.Development.json
/backend/API/appsettings.json
*bin
/backend/API/database.sqlite3
/backend/API/database.sqlite3-shm
/backend/API/database.sqlite3-wal

View File

@ -13,6 +13,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -1,127 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
using MySql.EntityFrameworkCore.Metadata;
#nullable disable
namespace API.Migrations
{
/// <inheritdoc />
public partial class RecipeModelAdded : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "PrefereredRecipesId",
table: "Users",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "PrefereredRecipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn)
},
constraints: table =>
{
table.PrimaryKey("PK_PrefereredRecipes", x => x.Id);
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "Recipes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false),
Description = table.Column<string>(type: "longtext", nullable: false),
Directions = table.Column<string>(type: "longtext", nullable: false),
PrefereredRecipesId = table.Column<int>(type: "int", 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");
})
.Annotation("MySQL:Charset", "utf8mb4");
migrationBuilder.CreateTable(
name: "Ingredient",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
Amount = table.Column<int>(type: "int", nullable: false),
Unit = table.Column<string>(type: "longtext", nullable: false),
Element = table.Column<string>(type: "longtext", nullable: false),
RecipeId = table.Column<int>(type: "int", 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");
})
.Annotation("MySQL:Charset", "utf8mb4");
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.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: "Recipes");
migrationBuilder.DropTable(
name: "PrefereredRecipes");
migrationBuilder.DropIndex(
name: "IX_Users_PrefereredRecipesId",
table: "Users");
migrationBuilder.DropColumn(
name: "PrefereredRecipesId",
table: "Users");
}
}
}

View File

@ -11,36 +11,34 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace API.Migrations
{
[DbContext(typeof(DBContext))]
[Migration("20250428070005_RecipeModelAdded")]
[Migration("20250429115336_RecipeModelAdded")]
partial class RecipeModelAdded
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.HasAnnotation("ProductVersion", "8.0.10");
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int>("Amount")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Element")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("RecipeId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Unit")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@ -53,7 +51,7 @@ namespace API.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.HasKey("Id");
@ -64,22 +62,22 @@ namespace API.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Directions")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("PrefereredRecipesId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.HasKey("Id");
@ -88,35 +86,65 @@ namespace API.Migrations
b.ToTable("Recipes");
});
modelBuilder.Entity("API.Models.ShoppingListModels.ShoppingList", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double>("Amount")
.HasColumnType("REAL");
b.Property<bool>("Checked")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Unit")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("UserId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ShoppingList");
});
modelBuilder.Entity("API.Models.UserModels.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int>("PrefereredRecipesId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("RefreshToken")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<DateTime>("RefreshTokenExpireAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Salt")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@ -139,6 +167,13 @@ namespace API.Migrations
.HasForeignKey("PrefereredRecipesId");
});
modelBuilder.Entity("API.Models.ShoppingListModels.ShoppingList", b =>
{
b.HasOne("API.Models.UserModels.User", null)
.WithMany("ShoppingList")
.HasForeignKey("UserId");
});
modelBuilder.Entity("API.Models.UserModels.User", b =>
{
b.HasOne("API.Models.RecipeModels.PrefereredRecipes", "PrefereredRecipes")
@ -159,6 +194,11 @@ namespace API.Migrations
{
b.Navigation("Ingredients");
});
modelBuilder.Entity("API.Models.UserModels.User", b =>
{
b.Navigation("ShoppingList");
});
#pragma warning restore 612, 618
}
}

View File

@ -0,0 +1,274 @@
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);
}
}
}

View File

@ -15,29 +15,27 @@ namespace API.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.HasAnnotation("ProductVersion", "8.0.10");
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<int>("Amount")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Element")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("RecipeId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Unit")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@ -50,7 +48,7 @@ namespace API.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.HasKey("Id");
@ -61,22 +59,22 @@ namespace API.Migrations
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Directions")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int?>("PrefereredRecipesId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.HasKey("Id");
@ -85,35 +83,65 @@ namespace API.Migrations
b.ToTable("Recipes");
});
modelBuilder.Entity("API.Models.ShoppingListModels.ShoppingList", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<double>("Amount")
.HasColumnType("REAL");
b.Property<bool>("Checked")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Unit")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int?>("UserId")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ShoppingList");
});
modelBuilder.Entity("API.Models.UserModels.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<int>("PrefereredRecipesId")
.HasColumnType("int");
.HasColumnType("INTEGER");
b.Property<string>("RefreshToken")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<DateTime>("RefreshTokenExpireAt")
.HasColumnType("datetime(6)");
.HasColumnType("TEXT");
b.Property<string>("Salt")
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.Property<string>("UserName")
.IsRequired()
.HasColumnType("longtext");
.HasColumnType("TEXT");
b.HasKey("Id");
@ -136,6 +164,13 @@ namespace API.Migrations
.HasForeignKey("PrefereredRecipesId");
});
modelBuilder.Entity("API.Models.ShoppingListModels.ShoppingList", b =>
{
b.HasOne("API.Models.UserModels.User", null)
.WithMany("ShoppingList")
.HasForeignKey("UserId");
});
modelBuilder.Entity("API.Models.UserModels.User", b =>
{
b.HasOne("API.Models.RecipeModels.PrefereredRecipes", "PrefereredRecipes")
@ -156,6 +191,11 @@ namespace API.Migrations
{
b.Navigation("Ingredients");
});
modelBuilder.Entity("API.Models.UserModels.User", b =>
{
b.Navigation("ShoppingList");
});
#pragma warning restore 612, 618
}
}