Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulty of challenges #12

Merged
merged 5 commits into from
Dec 26, 2024
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
4 changes: 4 additions & 0 deletions backend/Db/Dbo/Challenges/ChallengeDbo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using Models.Challenges;

namespace Db.Dbo.Challenges;

Expand All @@ -13,6 +14,9 @@ public class ChallengeDbo : Dbo

[Column("description")]
public string Description { get; set; } = null!;

[Column("difficulty")]
public ChallengeDifficulty Difficulty { get; set; }

[Column("categoryId")]
public Guid CategoryId { get; set; }
Expand Down
4 changes: 4 additions & 0 deletions backend/Db/Dbo/Challenges/SnapshotChallengeDbo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations.Schema;
using Models.Challenges;

namespace Db.Dbo.Challenges;

Expand All @@ -14,6 +15,9 @@ public class SnapshotChallengeDbo : Dbo
[Column("short_description")]
public string? ShortDescription { get; set; }

[Column("difficulty")]
public ChallengeDifficulty Difficulty { get; set; }

[Column("categoryId")]
public Guid CategoryId { get; set; }

Expand Down

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

40 changes: 40 additions & 0 deletions backend/Db/Migrations/20241128163144_AddChallengeDifficulty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Db.Migrations
{
/// <inheritdoc />
public partial class AddChallengeDifficulty : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "difficulty",
table: "challenges_snapshot",
type: "integer",
nullable: false,
defaultValue: 0);

migrationBuilder.AddColumn<int>(
name: "difficulty",
table: "challenges",
type: "integer",
nullable: false,
defaultValue: 0);
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "difficulty",
table: "challenges_snapshot");

migrationBuilder.DropColumn(
name: "difficulty",
table: "challenges");
}
}
}
12 changes: 11 additions & 1 deletion backend/Db/Migrations/DbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("ProductVersion", "8.0.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);

NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
Expand Down Expand Up @@ -63,6 +63,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("text")
.HasColumnName("description");

b.Property<int>("Difficulty")
.IsRequired()
.HasColumnType("integer")
.HasColumnName("difficulty");

b.Property<bool>("IsCatInBag")
.HasColumnType("boolean")
.HasColumnName("is_cat_in_bag");
Expand Down Expand Up @@ -107,6 +112,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("text")
.HasColumnName("description");

b.Property<int>("Difficulty")
.IsRequired()
.HasColumnType("integer")
.HasColumnName("difficulty");

b.Property<bool>("IsCatInBag")
.HasColumnType("boolean")
.HasColumnName("is_cat_in_bag");
Expand Down
3 changes: 2 additions & 1 deletion backend/Db/add-migration.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dotnet ef migrations add --project Db --startup-project KotnurVersus.Web $1
dotnet ef migrations add --project Db --startup-project KotnurVersus.Web $1
read -n 1 -s -r -p "Нажмите любую кнопку для завершения"
1 change: 1 addition & 0 deletions backend/Db/apply-migrations.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dotnet ef database update --project Db --startup-project KotnurVersus.Web
read -n 1 -s -r -p "Нажмите любую кнопку для завершения"
Loading