Class: StrongMigrations::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/strong_migrations/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#adapterObject



33
34
35
# File 'lib/generators/strong_migrations/install_generator.rb', line 33

def adapter
  ActiveRecord::Base.connection_config[:adapter].to_s
end

#create_initializerObject



8
9
10
# File 'lib/generators/strong_migrations/install_generator.rb', line 8

def create_initializer
  template "initializer.rb", "config/initializers/strong_migrations.rb"
end

#pgbouncer_messageObject



16
17
18
19
20
# File 'lib/generators/strong_migrations/install_generator.rb', line 16

def pgbouncer_message
  if postgresql?
    "\n# If you use PgBouncer in transaction mode, delete these lines and set timeouts on the database user"
  end
end

#postgresql?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/generators/strong_migrations/install_generator.rb', line 37

def postgresql?
  adapter =~ /postg/
end

#start_afterObject



12
13
14
# File 'lib/generators/strong_migrations/install_generator.rb', line 12

def start_after
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

#target_versionObject



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

def target_version
  case adapter
  when /mysql/
    # could try to connect to database and check for MariaDB
    # but this should be fine
    '"8.0.12"'
  else
    "10"
  end
end