Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew fong committed Jun 12, 2020
1 parent 9f114b4 commit af31ff8
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# ActiveRecord::LogDeleted

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/active_record/log_deleted`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem
Our data team needs to have logs of deleted rows. To do this, we historically have copy pasted some raw SQL from migration to migration. This gem exposes methods in ActiveRecord migrations to create the deleted row triggers.

## Installation

Expand All @@ -22,7 +20,46 @@ Or install it yourself as:

## Usage

TODO: Write usage instructions here
### Configuration

To override defaults, add an initializer:

```ruby
# config/initializers/active_record-log_deleted.rb
ActiveRecord::LogDeleted.configure do |config|
config.deleted_rows_table_name = :deleted_rows
config.log_deleted_row_function_name = :log_deleted_row
config.log_deleted_row_trigger_name = :log_deleted_row_trigger
end
```

### Create the deleted rows table
```ruby
class CreateDeletedRowsTable < ActiveRecord::Migration[6.0]
def change
create_deleted_rows_table
end
end
```

### Create the log deleted row function
```ruby
class CreateLogDeletedRowFunction < ActiveRecord::Migration[6.0]
def change
create_log_deleted_row_function
end
end
```

### Create the deleted row trigger
```ruby
class CreateDeletedRowTrigger < ActiveRecord::Migration[6.0]
def change
create_deleted_row_trigger(:table_name)
end
end
```


## Development

Expand Down

0 comments on commit af31ff8

Please sign in to comment.