Add extra unique constraints to DB jobs.
1. Can only have one high-priority job now. This actually got messed up for at least 10 people in the production DB and I fixed them manually. 2. Can't have duplicate jobs with the same name on the same profile.
This commit is contained in:
@@ -44,6 +44,18 @@ namespace Content.Server.Database
|
||||
.HasIndex(p => new {HumanoidProfileId = p.ProfileId, p.AntagName})
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder.Entity<Job>()
|
||||
.HasIndex(j => j.ProfileId);
|
||||
|
||||
modelBuilder.Entity<Job>()
|
||||
.HasIndex(j => j.ProfileId, "IX_job_one_high_priority")
|
||||
.IsUnique()
|
||||
.HasFilter("priority = 3");
|
||||
|
||||
modelBuilder.Entity<Job>()
|
||||
.HasIndex(j => new { j.ProfileId, j.JobName })
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder.Entity<AssignedUserId>()
|
||||
.HasIndex(p => p.UserName)
|
||||
.IsUnique();
|
||||
|
||||
Reference in New Issue
Block a user