Skip to content

Hangfire PostgreSQL: “column updatecount of relation lock already exists” during schema installation #425

Description

@wesleyisaacd

I am encountering an issue while using Hangfire with PostgreSQL where schema installation fails with the following error:

Hangfire attempts to re-run schema migration scripts, which include ALTER TABLE ADD COLUMN statements without checking if the column already exists. PostgreSQL throws an error when trying to add a duplicate column.
Version : Hangfire.PostgreSql V. 1.21.1
Exception :
column "updatecount" of relation "lock" already exists at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage) at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder1.StateMachineBox1.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken) at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken) at Npgsql.NpgsqlDataReader.NextResult() at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken) at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken) at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken) at Npgsql.NpgsqlCommand.ExecuteNonQuery() at Hangfire.PostgreSql.PostgreSqlObjectsInstaller.Install(NpgsqlConnection connection, String schemaName) Exception data: Severity: ERROR SqlState: 42701 MessageText: column "updatecount" of relation "lock" already exists File: tablecmds.c Line: 7686 Routine: check_for_column_name_collision

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions