Skip to content

Commit

Permalink
chore: Update one_off readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dbicanic committed May 10, 2023
1 parent e0de0c0 commit ad89ebb
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
# OneOff
Short description and motivation.
This gem allows you to run code that's needed for one time use. This can be deleting/editing specific records, moving
data between old and new columns, and a variety of other uses.

## Usage
How to use my plugin.
Generate a one_off:
```bash
$ rails/rake one_off g ${name of file}
```
It should be generated in the `db/one_off` directory. It'll look something like
`20230508202324_one_off_name.rb`

This will give you a file where you can add code to the `#perform` method.
```ruby
require 'one_off/environments'

module OneOff
class OneOffName
include Environments

environments :development, :production

def perform
#add task into here
end
end
end
```
To run this one_off locally, use the matching task
```bash
$ rails/rake one_off:matching\[name_of_one_off\]
```
To have this run in production, you'll want to add this line to your build script. This will run all the one_offs that
do not exist in the `one_off_tasks` database table.
```bash
$ bundle exec rake db:migrate one_off:run
```
## Installation
Add this line to your application's Gemfile:

Expand All @@ -21,6 +52,16 @@ Or install it yourself as:
$ gem install one_off
```

This gem requires a database table to track the one_offs that have already been run. Run the generate migration:
```bash
$ rails/rake one_off:install:migrations
```
This will create a new migration file in your main app. You'll need to run migrations for this to take place:
```bash
$ rails/rake db:migrate
```


## Contributing
Contribution directions go here.

Expand Down

0 comments on commit ad89ebb

Please sign in to comment.