Class: OutboxGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- OutboxGenerator
- Defined in:
- lib/active_outbox/generators/outbox_generator.rb
Instance Method Summary collapse
- #create_migration_files ⇒ Object
- #json_type ⇒ Object
- #migration_version ⇒ Object
- #postgres? ⇒ Boolean
- #table_name ⇒ Object
- #uuid_type ⇒ Object
Instance Method Details
#create_migration_files ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/active_outbox/generators/outbox_generator.rb', line 10 def create_migration_files migration_path = "#{['root_components_path']}/db/migrate" migration_template( "migration.rb", "#{migration_path}/outbox_create_#{table_name}.rb", migration_version: migration_version ) end |
#json_type ⇒ Object
31 32 33 |
# File 'lib/active_outbox/generators/outbox_generator.rb', line 31 def json_type postgres? ? 'jsonb' : 'string' end |
#migration_version ⇒ Object
19 20 21 |
# File 'lib/active_outbox/generators/outbox_generator.rb', line 19 def migration_version "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end |
#postgres? ⇒ Boolean
35 36 37 |
# File 'lib/active_outbox/generators/outbox_generator.rb', line 35 def postgres? ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql' end |
#table_name ⇒ Object
23 24 25 |
# File 'lib/active_outbox/generators/outbox_generator.rb', line 23 def table_name "#{name}_outboxes" end |
#uuid_type ⇒ Object
27 28 29 |
# File 'lib/active_outbox/generators/outbox_generator.rb', line 27 def uuid_type postgres? ? 'uuid' : 'string' end |