Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/EFCore.PG/Migrations/Internal/NpgsqlHistoryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ bool IHistoryRepository.CreateIfNotExists()
GetCreateIfNotExistsCommands(), Dependencies.Connection, new MigrationExecutionState(), commitTransaction: true)
!= 0;
}
catch (PostgresException e) when (e.SqlState is "23505" or "42P07")
catch (PostgresException e) when (e.SqlState is PostgresErrorCodes.UniqueViolation
or PostgresErrorCodes.DuplicateTable
or PostgresErrorCodes.DuplicateObject)
{
return false;
}
Expand All @@ -116,7 +118,9 @@ async Task<bool> IHistoryRepository.CreateIfNotExistsAsync(CancellationToken can
cancellationToken: cancellationToken).ConfigureAwait(false))
!= 0;
}
catch (PostgresException e) when (e.SqlState is "23505" or "42P07")
catch (PostgresException e) when (e.SqlState is PostgresErrorCodes.UniqueViolation
or PostgresErrorCodes.DuplicateTable
or PostgresErrorCodes.DuplicateObject)
{
return false;
}
Expand Down Expand Up @@ -192,7 +196,7 @@ public override IReadOnlyList<HistoryRow> GetAppliedMigrations()
{
return base.GetAppliedMigrations();
}
catch (PostgresException e) when (e.SqlState is "3D000" or "42P01")
catch (PostgresException e) when (e.SqlState is PostgresErrorCodes.InvalidCatalogName or PostgresErrorCodes.UndefinedTable)
{
return [];
}
Expand All @@ -210,7 +214,7 @@ public override async Task<IReadOnlyList<HistoryRow>> GetAppliedMigrationsAsync(
{
return await base.GetAppliedMigrationsAsync(cancellationToken).ConfigureAwait(false);
}
catch (PostgresException e) when (e.SqlState is "3D000" or "42P01")
catch (PostgresException e) when (e.SqlState is PostgresErrorCodes.InvalidCatalogName or PostgresErrorCodes.UndefinedTable)
{
return [];
}
Expand Down