Class: SidekiqSequence::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/sidekiq_sequence/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_migrationObject



14
15
16
17
# File 'lib/generators/sidekiq_sequence/install_generator.rb', line 14

def copy_migration
  migration_template 'migration.rb', 'db/migrate/create_sidekiq_sequence_record.rb',
                     migration_version: migration_version
end

#migration_versionObject



19
20
21
# File 'lib/generators/sidekiq_sequence/install_generator.rb', line 19

def migration_version
  "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
end

#properties_typeObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/sidekiq_sequence/install_generator.rb', line 23

def properties_type
  case ActiveRecord::Base.connection_db_config.adapter
  when /postg/i # postgres, postgis
    'jsonb'
  when /mysql/i
    'json'
  else
    'text'
  end
end