Hangfire.PostgreSql icon indicating copy to clipboard operation
Hangfire.PostgreSql copied to clipboard

Ability to have GUIDs as PK

Open ips-jm opened this issue 1 year ago • 4 comments

It would be great to have the option to use GUIDs as the Primary Key for jobs. Perhaps the appropriate place for this could be in the "PostgreSqlStorageOptions()" constructor?

I'm considering opening a pull request for this; I should have some time next week - if that feature is not already being worked on?

ips-jm avatar Dec 10 '23 20:12 ips-jm

It's not as trivial as changing the type with the options. Keep in mind the install SQL scripts have to be changed too. Technically not changed, but rather a new one has to be created which supports your newly supported type(-s). And what if you want to change the type later down the road? Or someone messes up and accidentally removes the property setter, and we default to long again?

Using uuid means we can no longer use serial for the database to increment the job IDs automatically, and PostgreSQL versions before 13 do not have built-in uuid generation and have to use an extra extension (e.g. uuid-ossp) for auto-generation. Some organisations have to go through some nasty loops to enable extensions on their PG instances.

With that in mind, I don't think the effort needed to have uuid as PK (optionally) for the job is worth it. What's the actual reason you want to have it?

azygis avatar Dec 11 '23 08:12 azygis

Postgres versions below 13 will be at end of life / support this year. That may help with implementing this change.

campbecf avatar Jan 11 '24 15:01 campbecf

I'm afraid enabling extensions (or not having to) is the least of the mentioned concerns. I personally find it hard to justify such a change without some valid use cases that I'm possibly not aware of.

Really hoping to hear some reasoning.

azygis avatar Jan 11 '24 16:01 azygis

Same here, would like reasoning.

But I think we are mixing things up. uuid-ossp is supplementary and not required for the uuid datatype itself. uuid-ossp just contains extra functions. So if we create guids in C# with NewGuid() and not use any uuid-ossp functions, we decrease the impact a lot already.

frankhommers avatar Jan 18 '24 12:01 frankhommers

Closing as it's not worth the effort right now, unless there's a good reason to. If there is one, we can reopen.

azygis avatar Apr 15 '24 09:04 azygis