Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
/WSIST/WSIST.Web/wwwroot/lib
/WSIST/WSIST.Web/bin
/WSIST/WSIST.UnitTests/obj
/WSIST/WSIST.UnitTests/obj
WSIST/WSIST.UnitTests/obj/Debug/net9.0/WSIST.UnitTests.csproj.AssemblyReference.cache
/WSIST/WSIST.UnitTests/obj
/WSIST/WSIST.UnitTests/bin
WSIST/WSIST.Engine/bin
WSIST/WSIST.Web/appsettings.Development.json
/WSIST/WSIST.Engine/bin
/WSIST/WSIST.Web/appsettings.Development.json
.claude
.env
coderabbit-full-review*.txt
2 changes: 1 addition & 1 deletion WSIST/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "1.2.4",
"version": "1.3.0",
"commands": [
"csharpier"
],
Expand Down
3 changes: 3 additions & 0 deletions WSIST/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copy to .env and customize. Used by docker-compose.yml for the local MySQL container.
MYSQL_ROOT_PASSWORD=password
MYSQL_DATABASE=wsistdb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

namespace WSIST.Engine.Migrations
{
/// <inheritdoc />
public partial class SubjectIdAutoIncrement : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// Move the seeded system subjects from ids 0..5 to -6..-1 *in place*
// (renumbering instead of delete+insert keeps every Tests.Subject
// reference intact), then turn the column into auto-increment so
// user-created subjects get database-generated ids. Renumbering must
// happen first: MySQL won't accept an auto-increment column that
// still holds a 0. FK checks stay off through the ALTER because the
// column is referenced by FK_Tests_Subjects_Subject.
migrationBuilder.Sql("SET FOREIGN_KEY_CHECKS = 0;");
migrationBuilder.Sql("UPDATE `Subjects` SET `Id` = `Id` - 6 WHERE `IsSystem` = 1 AND `Id` BETWEEN 0 AND 5;");
migrationBuilder.Sql("UPDATE `Tests` SET `Subject` = `Subject` - 6 WHERE `Subject` BETWEEN 0 AND 5;");

migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Subjects",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

migrationBuilder.Sql("SET FOREIGN_KEY_CHECKS = 1;");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
// Rollback limitation: if user-created subjects have claimed
// auto-increment ids 1..5 since the Up ran, shifting the system
// subjects back from -6..-1 to 0..5 would collide with them on the
// primary key and this migration would fail. There is no safe,
// automatic resolution — those user subjects would have to be
// renumbered manually first.
migrationBuilder.Sql("SET FOREIGN_KEY_CHECKS = 0;");

migrationBuilder.AlterColumn<int>(
name: "Id",
table: "Subjects",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

migrationBuilder.Sql("UPDATE `Subjects` SET `Id` = `Id` + 6 WHERE `IsSystem` = 1 AND `Id` BETWEEN -6 AND -1;");
migrationBuilder.Sql("UPDATE `Tests` SET `Subject` = `Subject` + 6 WHERE `Subject` BETWEEN -6 AND -1;");
migrationBuilder.Sql("SET FOREIGN_KEY_CHECKS = 1;");
}
}
}
17 changes: 10 additions & 7 deletions WSIST/WSIST.Engine/Migrations/WsistContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("ProductVersion", "9.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 64);

MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);

modelBuilder.Entity("WSIST.Engine.Subject", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));

b.Property<bool>("IsSystem")
.ValueGeneratedOnAdd()
.HasColumnType("tinyint(1)")
Expand All @@ -49,37 +52,37 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasData(
new
{
Id = 0,
Id = -6,
IsSystem = true,
Name = "Math"
},
new
{
Id = 1,
Id = -5,
IsSystem = true,
Name = "English"
},
new
{
Id = 2,
Id = -4,
IsSystem = true,
Name = "French"
},
new
{
Id = 3,
Id = -3,
IsSystem = true,
Name = "German"
},
new
{
Id = 4,
Id = -2,
IsSystem = true,
Name = "Chemistry"
},
new
{
Id = 5,
Id = -1,
IsSystem = true,
Name = "Other"
});
Expand Down
4 changes: 2 additions & 2 deletions WSIST/WSIST.Engine/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public static string VolumeHelper(TestVolume volume)
return "Please Choose a Setting";
}

public static string UnderstandingHelper(PersonalUnderstanding volume)
public static string UnderstandingHelper(PersonalUnderstanding understanding)
{
switch (volume)
switch (understanding)
{
case PersonalUnderstanding.VeryLow:
{
Expand Down
Loading
Loading