{"id":13878745,"url":"https://github.com/ayushn21/maintenance_job","last_synced_at":"2025-02-24T19:56:44.304Z","repository":{"id":56882628,"uuid":"421170067","full_name":"ayushn21/maintenance_job","owner":"ayushn21","description":"Mechanism to run testable one-off jobs in Rails at deploy time to manipulate data","archived":false,"fork":false,"pushed_at":"2024-08-24T20:04:14.000Z","size":59,"stargazers_count":30,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-11T23:19:46.578Z","etag":null,"topics":["activejob","deploy","deployment","migration","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayushn21.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-25T20:09:55.000Z","updated_at":"2024-10-04T13:23:13.000Z","dependencies_parsed_at":"2024-10-26T04:50:17.652Z","dependency_job_id":"14b9d891-aa2f-4572-8258-342d893e2e6c","html_url":"https://github.com/ayushn21/maintenance_job","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.15625,"last_synced_commit":"f060c1277f2589b272bdfd009a08e9d40eb6efa8"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayushn21%2Fmaintenance_job","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayushn21%2Fmaintenance_job/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayushn21%2Fmaintenance_job/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayushn21%2Fmaintenance_job/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayushn21","download_url":"https://codeload.github.com/ayushn21/maintenance_job/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240549434,"owners_count":19819131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activejob","deploy","deployment","migration","rails"],"created_at":"2024-08-06T08:01:58.562Z","updated_at":"2025-02-24T19:56:44.285Z","avatar_url":"https://github.com/ayushn21.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# MaintenanceJob\n\n[![Tests](https://github.com/ayushn21/maintenance_job/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/ayushn21/maintenance_job/actions/workflows/tests.yml)\n[![Gem Version](https://badge.fury.io/rb/maintenance_job.svg)](https://badge.fury.io/rb/maintenance_job)\n\n`MaintenanceJob` is a lightweight Rails engine to run testable one-off jobs at deploy time to manipulate data in the database.\n\nTheoretically this could be done in database migrations or rake tasks, but that's a terrible idea because the changes can't be tested. In the case of rake tasks, it would also require access to the prod environment to run the tasks which is not always feasible.\n\nThis gem was heavily inspired by [this RailsConf 2020 talk](https://railsconf.org/2020/2020/video/alec-clarke-measure-twice-cut-once) by [@alecclarke](https://github.com/alecclarke).\n\n## Installation\nAdd this line to your Rails application's Gemfile:\n\n```ruby\ngem 'maintenance_job'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install \u0026\u0026 bin/rails maintenance_job:install\n```\n\nThis will copy the database migration that tracks which maintenance jobs have been run and create a directory under `app/jobs` for all your maintenance jobs.\n\n## Usage\n\n### Run maintenance jobs on deploy\n\nAdd `bin/rails maintenance_job:execute_pending_jobs` to your deploy script right after you run the database migrations.\n\n### Creating a maintenance job\n\nTo create a new maintenance job, run:\n\n```bash\n$ bin/rails generate maintenance_job job_to_be_done\n```\n\nThis will create two files:\n\n- `app/jobs/maintenance/job_to_be_done_job.rb`\n- `test/jobs/maintenance/job_to_be_done_job_test.rb`\n\nImplement your data manipulation, write some tests for it and deploy!\n\n### Ensuring all jobs have been run in local environments\n\nIf you'd like to ensure any pending maintenance jobs have been run in the development environment, add the following line to your `ApplicationController`:\n\n`include MaintenanceJob::EnsureNoPendingJobs if Rails.env.development?`\n\nIf there are any pending jobs in development, the developer will see an actionable error in the browser where they can run the pending jobs and continue.\n\n## Contributing\n\n1. Fork it (https://github.com/ayushn21/maintenance_job/fork)\n2. Clone the fork using `git clone` to your local development machine.\n3. Create your feature branch (`git checkout -b my-new-feature`)\n4. Commit your changes (`git commit -am 'Add some feature'`)\n5. Push to the branch (`git push origin my-new-feature`)\n6. Create a new Pull Request\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayushn21%2Fmaintenance_job","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayushn21%2Fmaintenance_job","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayushn21%2Fmaintenance_job/lists"}