mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-17 21:05:48 -04:00
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace AliasServerDb.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class ReplaceEmailToLocalIndexWithToDateSystem : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
// CONCURRENTLY avoids the ACCESS EXCLUSIVE lock that a plain CREATE/DROP INDEX
|
|
// would take on the Emails table. Requires running outside a transaction.
|
|
migrationBuilder.Sql(
|
|
"DROP INDEX CONCURRENTLY IF EXISTS \"IX_Emails_ToLocal\";",
|
|
suppressTransaction: true);
|
|
|
|
migrationBuilder.Sql(
|
|
"CREATE INDEX CONCURRENTLY IF NOT EXISTS \"IX_Emails_To_DateSystem\" ON \"Emails\" (\"To\", \"DateSystem\");",
|
|
suppressTransaction: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.Sql(
|
|
"DROP INDEX CONCURRENTLY IF EXISTS \"IX_Emails_To_DateSystem\";",
|
|
suppressTransaction: true);
|
|
|
|
migrationBuilder.Sql(
|
|
"CREATE INDEX CONCURRENTLY IF NOT EXISTS \"IX_Emails_ToLocal\" ON \"Emails\" (\"ToLocal\");",
|
|
suppressTransaction: true);
|
|
}
|
|
}
|
|
}
|