-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Enable DB table names customization #535
Enable DB table names customization #535
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic! And simple 🙌
@dimvic fyi, in your application, you should be overriding the table name for This PR is great btw, just wanted to clarify the models. |
Thanks! Would you like me to add tests for this? Would only take a couple more introduced in Just for reference, being explicit, to use different table names you need to 1. adjust the generated migrations and 2. add this to app/environment config or an initialiser:
|
@dimvic yep, that's exactly right. I don't think this needs tests because it's largely how ActiveRecord works. It does make me think that I should make |
Thank you very very much. I agree that since the table name is shared between the two it is would be beneficial to have it delegated, but I don't see much more use to it other than making it easier to customise table names. Ping me if you'd like me to do something more about this, I'd be more than happy to. |
With this patch it is possible to assign custom table names for
GoodJob::Process
andGoodJob::ActiveJobJob
and havegood_job
function as usual.It enables the use of a common database for two or more schedulers while keeping the dashboard functional.
My motive was working on two apps that share a database and both need to run a scheduler and we want to run
good_job
because well, it's too good for our use case :). I believe this is a legit, while ugly, requirement in some projects.There is no need to complicate things by making the migrations take the custom table names into account for upgrades. It is possible, but the added complexity would possibly make migrations fragile and certainly harder to reason about. After all, anyone who opts to change the table name this way would review migrations coming from updates before running them. Even if not, they would fail and the person would iterate.
The table names have been added without quoting into the SQL code because, well, it's a table name.
I like to believe that the only reason to consider not including this is that future code would need to use table names via model classes instead of hardcoded, which is not necessarily a bad thing.