-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Custom table names #748
Comments
@gap777 Thanks for opening the issue and sorry about the inconvenience! Those models became autoloaded. You should be able to do this in an an initializer: # config/initializers/good_job.rb
Rails.application.reloader.to_prepare do
GoodJob::Execution.table_name = 'my_good_jobs'
GoodJob::Process.table_name = 'my_good_job_processes'
GoodJob::Setting.table_name = 'my_good_job_settings' # <- new database backed model
end Edit: |
@bensheldon, I am getting the following error with the above configuration. /Users/admin/.rvm/gems/ruby-3.2.0/gems/good_job-3.8.0/app/models/good_job/job.rb:24:in `table_name=': Assign GoodJob::Execution.table_name directly (NotImplementedError) What is the correct configuration in the latest version? |
@remy727 oops, you don't need to set the table name for good_job/app/models/good_job/job.rb Lines 21 to 25 in 430a6a0
|
Thank you for your reply @bensheldon |
@remy727 oh! Migrations/Schema and Model configuration aren't connected. If you want to rename the tables themselves, you'll have to write your own migrations. |
Got it. Thank you for confirming @bensheldon! |
I tried using the custom initializer code above and updated the migration to match my new table names. But, when I relaunch the app after migrating, I'm seeing this error a lot in my logs:
Is there any way to disable that? |
@mokolabs sorry about that! I maybe hardcoded a tablename in one of those checks 😰 I'll take a look because that is annoying. |
I tried customizing them myself. I'm not seeing the migration warning, but I had to add a bunch more overrides: Rails.application.reloader.to_prepare do
GoodJob::BaseExecution.table_name = 'c_good_jobs'
GoodJob::BatchRecord.table_name = 'c_good_jobs'
GoodJob::DiscreteExecution.table_name = 'c_good_job_executions'
GoodJob::Execution.table_name = 'c_good_jobs'
GoodJob::Process.table_name = 'c_good_job_processes'
GoodJob::Setting.table_name = 'c_good_job_settings'
end |
That's what mine looks like these days:
|
FWIW, I'm not seeing the warning with the latest build... I think there one or two regressions in that particular area since the bug was originally fixed, though those have already been fixed as well in the latest. |
@bensheldon @gap777 Thank you for the quick reply! I'll give it another go. 👍🏻 |
@bensheldon @gap777 That worked. Thanks again! For those who wish to go down this path, here's everything you need to do it:
|
As of https://github.com/bensheldon/good_job/releases/tag/v2.11.2, good_jobs supported custom table names. However, this seems not to work anymore. Specifically, trying to set them in a config initializer
generates errors like:
Is there another way to configure this, or is this capability lost?
Can it be restored?
Thank you!
The text was updated successfully, but these errors were encountered: