Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding prefix to table names #1557

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Adding prefix to table names #1557

wants to merge 2 commits into from

Conversation

girakun
Copy link

@girakun girakun commented Nov 5, 2019

We have some old running software connecting to the same SQL database as our new software. The old software do some stuff that ignores schema and as some of our tables has the same name as some of Hangfires it cause problems. I did also see two old pull request where someone where looking for something similar to this. (Pull request 1097 and 1301)

We have not upgraded Hangfire for a while, but we have used this since we started using Hangfire two years ago. I now updated our code base from the latest version and i figured i could share this, if this is interesting for someone else.

It is done in the quickest way possible (search and replace) and is probably not the best implementation, but it has been working for us. It's possible to create a better implementation (Example: Something that doesn't require manual add of the prefix before the table every time) but then i want to be sure that it is a feature that will be taken in consideration for the official version, before i put the time in to do so.

Quick about the implementation that is made so far. It's implemented in the same way custom scheme name is implemented. It has support for changing prefix over time as of now it is running when PrepareSchemaIfNecessary = true, maybe this should be moved to some other place or only run when EnableHeavyMigrations = true. Default there is no prefix. If prefix is set and tables do not correspond with prefix it will cause and exception at initialization of SQL storage.

@pieceofsummer
Copy link
Contributor

Is there any reason you cannot use a separate database for Hangfire storage, so table names don't overlap with your software?

@CzechsMix
Copy link

@pieceofsummer

I had a similar question, and I could use a separate database for hangfire storage, but I have multiple services each with their own database.

I don't like the idea of using a single hangfire storage for all services, but it seems like a large effort to have a hangfire datbase for each service that will use hangfire.

dbo.ServiceA
dbo.ServiaA_Hangfire
dbo.ServiceB
dbo.ServiceB_Hangfire

Ideally, I could just point hangfire at the SqlServer database for that application, and it would just prefix it's tables with "Hangfire_" or something to not conflict with the other tables.

If a second database for each service that uses hangfire is the way to go then I guess I could make due, but ideally I'd like to specify a prefix.

@burningice2866
Copy link
Contributor

Use Schemas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants