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:
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Content.Server.Database.Migrations.Postgres
|
||||
{
|
||||
public partial class UniqueHighPriorityJob : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_job_one_high_priority",
|
||||
table: "job",
|
||||
column: "profile_id",
|
||||
unique: true,
|
||||
filter: "priority = 3");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_job_profile_id_job_name",
|
||||
table: "job",
|
||||
columns: new[] { "profile_id", "job_name" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_job_one_high_priority",
|
||||
table: "job");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_job_profile_id_job_name",
|
||||
table: "job");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user