Skip to content

Commit

Permalink
FIX: Cannot delete from table "lock" because it does not have a repli…
Browse files Browse the repository at this point in the history
…ca identity and publishes deletes #312
  • Loading branch information
Shaddix committed Jul 12, 2023
1 parent 3949e31 commit 4914923
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Hangfire.PostgreSql/Scripts/Install.v21.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SET search_path = 'hangfire';

DO $$
BEGIN
IF EXISTS(SELECT 1 FROM "schema" WHERE "version"::integer >= 21) THEN
RAISE EXCEPTION 'version-already-applied';
END IF;
END $$;

-- Set REPLICA IDENTITY to allow replication
ALTER TABLE "lock" REPLICA IDENTITY USING INDEX "lock_resource_key";

RESET search_path;
4 changes: 2 additions & 2 deletions tests/Hangfire.PostgreSql.Tests/PostgreSqlInstallerFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void InstallingSchemaUpdatesVersionAndShouldNotThrowAnException()
PostgreSqlObjectsInstaller.Install(connection, schemaName);
int lastVersion = connection.Query<int>($@"SELECT version FROM ""{schemaName}"".""schema""").Single();
Assert.Equal(20, lastVersion);
Assert.Equal(21, lastVersion);
connection.Execute($@"DROP SCHEMA ""{schemaName}"" CASCADE;");
});
Expand All @@ -38,7 +38,7 @@ public void InstallingSchemaWithCapitalsUpdatesVersionAndShouldNotThrowAnExcepti
PostgreSqlObjectsInstaller.Install(connection, schemaName);
int lastVersion = connection.Query<int>($@"SELECT version FROM ""{schemaName}"".""schema""").Single();
Assert.Equal(20, lastVersion);
Assert.Equal(21, lastVersion);
connection.Execute($@"DROP SCHEMA ""{schemaName}"" CASCADE;");
});
Expand Down

0 comments on commit 4914923

Please sign in to comment.