mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-02-14 19:29:57 +01:00
2317
Content.Server.Database/Migrations/Postgres/20251018200752_Skills.Designer.cs
generated
Normal file
2317
Content.Server.Database/Migrations/Postgres/20251018200752_Skills.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Content.Server.Database.Migrations.Postgres
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Skills : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "profile_job_skills",
|
||||
columns: table => new
|
||||
{
|
||||
profile_job_skills_id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
profile_id = table.Column<int>(type: "integer", nullable: false),
|
||||
job_name = table.Column<string>(type: "text", nullable: false),
|
||||
skills = table.Column<string>(type: "jsonb", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_profile_job_skills", x => x.profile_job_skills_id);
|
||||
table.ForeignKey(
|
||||
name: "FK_profile_job_skills_profile_profile_id",
|
||||
column: x => x.profile_id,
|
||||
principalTable: "profile",
|
||||
principalColumn: "profile_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_profile_job_skills_profile_id_job_name",
|
||||
table: "profile_job_skills",
|
||||
columns: new[] { "profile_id", "job_name" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "profile_job_skills");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1040,6 +1040,38 @@ namespace Content.Server.Database.Migrations.Postgres
|
||||
b.ToTable("profile", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileJobSkills", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("profile_job_skills_id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("JobName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("job_name");
|
||||
|
||||
b.Property<int>("ProfileId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("profile_id");
|
||||
|
||||
b.Property<string>("Skills")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("skills");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK_profile_job_skills");
|
||||
|
||||
b.HasIndex("ProfileId", "JobName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("profile_job_skills", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileLoadout", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -1901,6 +1933,18 @@ namespace Content.Server.Database.Migrations.Postgres
|
||||
b.Navigation("Preference");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileJobSkills", b =>
|
||||
{
|
||||
b.HasOne("Content.Server.Database.Profile", "Profile")
|
||||
.WithMany("JobSkills")
|
||||
.HasForeignKey("ProfileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK_profile_job_skills_profile_profile_id");
|
||||
|
||||
b.Navigation("Profile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileLoadout", b =>
|
||||
{
|
||||
b.HasOne("Content.Server.Database.ProfileLoadoutGroup", "ProfileLoadoutGroup")
|
||||
@@ -2218,6 +2262,8 @@ namespace Content.Server.Database.Migrations.Postgres
|
||||
{
|
||||
b.Navigation("Antags");
|
||||
|
||||
b.Navigation("JobSkills");
|
||||
|
||||
b.Navigation("JobSubnames");
|
||||
|
||||
b.Navigation("JobUnblockings");
|
||||
|
||||
2232
Content.Server.Database/Migrations/Sqlite/20251018200740_Skills.Designer.cs
generated
Normal file
2232
Content.Server.Database/Migrations/Sqlite/20251018200740_Skills.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Content.Server.Database.Migrations.Sqlite
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Skills : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "profile_job_skills",
|
||||
columns: table => new
|
||||
{
|
||||
profile_job_skills_id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
profile_id = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
job_name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
skills = table.Column<string>(type: "jsonb", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_profile_job_skills", x => x.profile_job_skills_id);
|
||||
table.ForeignKey(
|
||||
name: "FK_profile_job_skills_profile_profile_id",
|
||||
column: x => x.profile_id,
|
||||
principalTable: "profile",
|
||||
principalColumn: "profile_id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_profile_job_skills_profile_id_job_name",
|
||||
table: "profile_job_skills",
|
||||
columns: new[] { "profile_id", "job_name" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "profile_job_skills");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -985,6 +985,36 @@ namespace Content.Server.Database.Migrations.Sqlite
|
||||
b.ToTable("profile", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileJobSkills", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("profile_job_skills_id");
|
||||
|
||||
b.Property<string>("JobName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("job_name");
|
||||
|
||||
b.Property<int>("ProfileId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("profile_id");
|
||||
|
||||
b.Property<string>("Skills")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("skills");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("PK_profile_job_skills");
|
||||
|
||||
b.HasIndex("ProfileId", "JobName")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("profile_job_skills", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileLoadout", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -1818,6 +1848,18 @@ namespace Content.Server.Database.Migrations.Sqlite
|
||||
b.Navigation("Preference");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileJobSkills", b =>
|
||||
{
|
||||
b.HasOne("Content.Server.Database.Profile", "Profile")
|
||||
.WithMany("JobSkills")
|
||||
.HasForeignKey("ProfileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("FK_profile_job_skills_profile_profile_id");
|
||||
|
||||
b.Navigation("Profile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.ProfileLoadout", b =>
|
||||
{
|
||||
b.HasOne("Content.Server.Database.ProfileLoadoutGroup", "ProfileLoadoutGroup")
|
||||
@@ -2135,6 +2177,8 @@ namespace Content.Server.Database.Migrations.Sqlite
|
||||
{
|
||||
b.Navigation("Antags");
|
||||
|
||||
b.Navigation("JobSkills");
|
||||
|
||||
b.Navigation("JobSubnames");
|
||||
|
||||
b.Navigation("JobUnblockings");
|
||||
|
||||
@@ -9,6 +9,8 @@ using System.Net;
|
||||
using System.Text.Json;
|
||||
using Content.Shared.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking; // WL-Skills
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; // WL-Skills
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace Content.Server.Database
|
||||
@@ -46,6 +48,7 @@ namespace Content.Server.Database
|
||||
public DbSet<RoleWhitelist> RoleWhitelists { get; set; } = null!;
|
||||
public DbSet<BanTemplate> BanTemplate { get; set; } = null!;
|
||||
public DbSet<IPIntelCache> IPIntelCache { get; set; } = null!;
|
||||
public DbSet<ProfileJobSkills> ProfileJobSkills { get; set; } = null!; // WL-Skills
|
||||
|
||||
//WL-Changes-start
|
||||
public DbSet<DiscordConnection> DiscordConnections { get; set; } = null!;
|
||||
@@ -123,6 +126,30 @@ namespace Content.Server.Database
|
||||
modelBuilder.Entity<JobSubname>()
|
||||
.HasIndex(j => new { j.ProfileId, j.JobName })
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder.Entity<ProfileJobSkills>(entity =>
|
||||
{
|
||||
var converter = new ValueConverter<Dictionary<byte, int>, string>(
|
||||
v => JsonSerializer.Serialize(v, (JsonSerializerOptions)null!),
|
||||
v => JsonSerializer.Deserialize<Dictionary<byte, int>>(v, (JsonSerializerOptions)null!) ?? new());
|
||||
|
||||
var comparer = new ValueComparer<Dictionary<byte, int>>(
|
||||
(l, r) => l != null && r != null && l.SequenceEqual(r),
|
||||
v => v.Aggregate(0, (a, p) => HashCode.Combine(a, p.Key.GetHashCode(), p.Value.GetHashCode())),
|
||||
v => v.ToDictionary(kv => kv.Key, kv => kv.Value));
|
||||
|
||||
entity.Property(e => e.Skills)
|
||||
.HasConversion(converter)
|
||||
.Metadata.SetValueComparer(comparer);
|
||||
|
||||
entity.HasIndex(p => new { p.ProfileId, p.JobName })
|
||||
.IsUnique();
|
||||
|
||||
entity.HasOne(e => e.Profile)
|
||||
.WithMany(e => e.JobSkills)
|
||||
.HasForeignKey(e => e.ProfileId)
|
||||
.IsRequired();
|
||||
});
|
||||
//WL-Changes-end
|
||||
|
||||
modelBuilder.Entity<AssignedUserId>()
|
||||
@@ -455,6 +482,7 @@ namespace Content.Server.Database
|
||||
public List<Antag> Antags { get; } = new();
|
||||
public List<Trait> Traits { get; } = new();
|
||||
public List<JobSubname> JobSubnames { get; } = new(); //WL-Subnames
|
||||
public List<ProfileJobSkills> JobSkills { get; } = new(); // WL-Skills
|
||||
|
||||
public List<JobUnblocking> JobUnblockings { get; } = new(); //WL-Changes
|
||||
public List<ProfileRoleLoadout> Loadouts { get; } = new();
|
||||
@@ -606,10 +634,29 @@ namespace Content.Server.Database
|
||||
/*
|
||||
* Insert extra data here like custom descriptions or colors or whatever.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// WL-Skills-start
|
||||
#region Job Skills
|
||||
|
||||
public class ProfileJobSkills
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ProfileId { get; set; }
|
||||
public Profile Profile { get; set; } = null!;
|
||||
|
||||
public string JobName { get; set; } = string.Empty;
|
||||
|
||||
[Column(TypeName = "jsonb")]
|
||||
public Dictionary<byte, int> Skills { get; set; } = new();
|
||||
}
|
||||
|
||||
#endregion
|
||||
// WL-Skills-end
|
||||
|
||||
public enum DbPreferenceUnavailableMode
|
||||
{
|
||||
// These enum values HAVE to match the ones in PreferenceUnavailableMode in Shared.
|
||||
|
||||
Reference in New Issue
Block a user