Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/delayed_job_json
https://github.com/kanety/delayed_job_json
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanety/delayed_job_json
- Owner: kanety
- License: mit
- Created: 2023-05-03T13:43:04.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-21T00:43:08.000Z (3 months ago)
- Last Synced: 2024-12-25T04:04:42.710Z (23 days ago)
- Language: Ruby
- Size: 22.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DelayedJobJson
Migrate handler of text column to json column for delayed_job.
## Dependencies
* ruby 2.7+
* activerecord 6.0+
* delayed_job 4.1
* delayed_job_active_record 4.1## Installation
Add this line to your application's Gemfile:
```ruby
gem 'delayed_job_json'
```And then execute:
$ bundle
## Usage
Generate migration files:
$ rails generate delayed_job_json:migration
Edit generated files and leave codes only for your database. An example of generated file is shown as follows:
```ruby
class AddPayloadToDelayedJobs < ActiveRecord::Migration[7.0]
def up
case ENV['DATABASE']
when 'postgresql'
add_column :delayed_jobs, :payload, :jsonb, null: false, default: {}
add_index :delayed_jobs, :payload, using: :gin
when 'mysql'
add_column :delayed_jobs, :payload, :json
else
add_column :delayed_jobs, :payload, :json, null: false, default: {}
end
enddef down
case ENV['DATABASE']
when 'postgresql'
remove_column :delayed_jobs, :payload, :jsonb, null: false, default: {}
when 'mysql'
remove_column :delayed_jobs, :payload, :json
else
remove_column :delayed_jobs, :payload, :json, null: false, default: {}
end
end
end
```Then run migration:
$ rake db:migrate
This migration adds `payload` column to delayed_jobs table, and YAML data in `handler` column is migrated to `payload` as json data.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kanety/delayed_job_json.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).