[backend/database] Resync constraint/index differences between native .net databases and ones migrated from -js
This commit is contained in:
parent
21ce68bcaa
commit
b7646f4d6c
2 changed files with 43 additions and 3 deletions
|
@ -13,9 +13,10 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
|
|||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_user_token",
|
||||
table: "user");
|
||||
migrationBuilder.Sql("""
|
||||
ALTER TABLE "user" DROP CONSTRAINT IF EXISTS "IX_user_token";
|
||||
DROP INDEX IF EXISTS "IX_user_token";
|
||||
""");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "hideOnlineStatus",
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Iceshrimp.Backend.Core.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20240712174827_ConvertConstraintsToUniqueIndicies")]
|
||||
public partial class ConvertConstraintsToUniqueIndicies : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("""
|
||||
ALTER TABLE "user" DROP CONSTRAINT IF EXISTS "IX_user_avatarId";
|
||||
ALTER TABLE "user" DROP CONSTRAINT IF EXISTS "IX_user_bannerId";
|
||||
ALTER TABLE "user_profile" DROP CONSTRAINT IF EXISTS "IX_user_profile_pinnedPageId";
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "IX_user_avatarId" ON "user" ("avatarId");
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "IX_user_bannerId" ON "user" ("bannerId");
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "IX_user_profile_pinnedPageId" ON "user_profile" ("pinnedPageId");
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("""
|
||||
DROP INDEX "IX_user_avatarId";
|
||||
DROP INDEX "IX_user_bannerId";
|
||||
DROP INDEX "IX_user_profile_pinnedPageId";
|
||||
ALTER TABLE "user" ADD CONSTRAINT "IX_user_avatarId" UNIQUE ("avatarId");
|
||||
ALTER TABLE "user" ADD CONSTRAINT "IX_user_bannerId" UNIQUE ("bannerId");
|
||||
ALTER TABLE "user_profile" ADD CONSTRAINT "IX_user_profile_pinnedPageId" UNIQUE ("pinnedPageId");
|
||||
""");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue