Skip to content

Commit

Permalink
Fix migration generator (#17)
Browse files Browse the repository at this point in the history
* Fix migration name in generator template

* Update setup order in readme

* Bump version
  • Loading branch information
guillermoap committed Nov 8, 2023
1 parent d68dd96 commit ca89cd4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
active_outbox (0.1.0)
active_outbox (0.1.1)
dry-configurable (~> 1.0)
rails (>= 6.1)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ gem install active_outbox

## Usage
### Setup
Create an `Outbox` table using the provided generator and corresponding model. Any model name can be passed as an argument but if empty it will default to just `Outobx`. The generated table name will be `model_name_outboxes`.
Create an initializer under `config/initializers/active_outbox.rb` and setup the default outbox class to the new `Outbox` model you just created.
```bash
rails g active_outbox:model <optional model_name>
rails g active_outbox:install
```
After running the migration, create an initializer under `config/initializers/active_outbox.rb` and setup the default outbox class to the new `Outbox` model you just created.
After creating the initializer, create an `Outbox` table using the provided generator and corresponding model. Any model name can be passed as an argument but if empty it will default to just `Outobx`. The generated table name will be `model_name_outboxes`.
```bash
rails g active_outbox:install
rails g active_outbox:model <optional model_name>
```

To allow models to store Outbox records on changes, you will have to include the `Outboxable` concern.
Expand Down
2 changes: 1 addition & 1 deletion active_outbox.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Gem::Specification.new do |spec|
spec.files = Dir['LICENSE.txt', 'README.md', 'lib/**/*', 'lib/active_outbox.rb']
spec.name = 'active_outbox'
spec.summary = 'A Transactional Outbox implementation for ActiveRecord'
spec.version = '0.1.0'
spec.version = '0.1.1'

spec.email = 'guillermoaguirre1@gmail.com'
spec.executables = ['outbox']
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/active_outbox/templates/migration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class ActiveOutboxCreate<%= table_name.camelize.singularize %> < ActiveRecord::Migration<%= migration_version %>
class ActiveOutboxCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %>
def change
create_table :<%= table_name %> do |t|
t.<%= ActiveOutbox::AdapterHelper.uuid_type %> :identifier, null: false, index: { unique: true }
Expand Down
12 changes: 6 additions & 6 deletions spec/lib/active_outbox/generators/model_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

let(:expected_content) do
<<~MIGRATION
class ActiveOutboxCreateOutbox < ActiveRecord::Migration[#{active_record_dependency}]
class ActiveOutboxCreateOutboxes < ActiveRecord::Migration[#{active_record_dependency}]
def change
create_table :outboxes do |t|
t.string :identifier, null: false, index: { unique: true }
Expand Down Expand Up @@ -91,7 +91,7 @@ def change

let(:expected_content) do
<<~MIGRATION
class ActiveOutboxCreateOutbox < ActiveRecord::Migration[#{active_record_dependency}]
class ActiveOutboxCreateOutboxes < ActiveRecord::Migration[#{active_record_dependency}]
def change
create_table :outboxes do |t|
t.string :identifier, null: false, index: { unique: true }
Expand Down Expand Up @@ -120,7 +120,7 @@ def change

let(:expected_content) do
<<~MIGRATION
class ActiveOutboxCreateOutbox < ActiveRecord::Migration[#{active_record_dependency}]
class ActiveOutboxCreateOutboxes < ActiveRecord::Migration[#{active_record_dependency}]
def change
create_table :outboxes do |t|
t.uuid :identifier, null: false, index: { unique: true }
Expand Down Expand Up @@ -178,7 +178,7 @@ def change

let(:expected_content) do
<<~MIGRATION
class ActiveOutboxCreate#{table_name.camelcase}Outbox < ActiveRecord::Migration[#{active_record_dependency}]
class ActiveOutboxCreate#{table_name.camelize}Outboxes < ActiveRecord::Migration[#{active_record_dependency}]
def change
create_table :#{table_name}_outboxes do |t|
t.string :identifier, null: false, index: { unique: true }
Expand Down Expand Up @@ -207,7 +207,7 @@ def change

let(:expected_content) do
<<~MIGRATION
class ActiveOutboxCreate#{table_name.camelcase}Outbox < ActiveRecord::Migration[#{active_record_dependency}]
class ActiveOutboxCreate#{table_name.camelize}Outboxes < ActiveRecord::Migration[#{active_record_dependency}]
def change
create_table :#{table_name}_outboxes do |t|
t.string :identifier, null: false, index: { unique: true }
Expand Down Expand Up @@ -236,7 +236,7 @@ def change

let(:expected_content) do
<<~MIGRATION
class ActiveOutboxCreate#{table_name.camelcase}Outbox < ActiveRecord::Migration[#{active_record_dependency}]
class ActiveOutboxCreate#{table_name.camelize}Outboxes < ActiveRecord::Migration[#{active_record_dependency}]
def change
create_table :#{table_name}_outboxes do |t|
t.uuid :identifier, null: false, index: { unique: true }
Expand Down

0 comments on commit ca89cd4

Please sign in to comment.