fix(backend): add unique index to auth methods
This commit is contained in:
parent
8b1d5b2c1b
commit
4780be3019
3 changed files with 73 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
|||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Foxnouns.Backend.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20241128202508_AddAuthMethodUniqueIndex")]
|
||||
public partial class AddAuthMethodUniqueIndex : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_auth_methods_auth_type_remote_id",
|
||||
table: "auth_methods",
|
||||
columns: new[] { "auth_type", "remote_id" },
|
||||
unique: true,
|
||||
filter: "fediverse_application_id IS NULL"
|
||||
);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_auth_methods_auth_type_remote_id_fediverse_application_id",
|
||||
table: "auth_methods",
|
||||
columns: new[] { "auth_type", "remote_id", "fediverse_application_id" },
|
||||
unique: true,
|
||||
filter: "fediverse_application_id IS NOT NULL"
|
||||
);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_auth_methods_auth_type_remote_id",
|
||||
table: "auth_methods"
|
||||
);
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "ix_auth_methods_auth_type_remote_id_fediverse_application_id",
|
||||
table: "auth_methods"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue