Module: Rails::Generators::Database

Included in:
AppBase, Rails::Generators::Db::System::ChangeGenerator
Defined in:
railties/lib/rails/generators/database.rb

Overview

:nodoc:

Constant Summary collapse

JDBC_DATABASES =
%w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
DATABASES =
%w( mysql postgresql sqlite3 oracle sqlserver ) + JDBC_DATABASES

Instance Method Summary collapse

Instance Method Details

#convert_database_option_for_jrubyObject



29
30
31
32
33
34
35
36
37
38
39
# File 'railties/lib/rails/generators/database.rb', line 29

def convert_database_option_for_jruby
  if defined?(JRUBY_VERSION)
    opt = options.dup
    case opt[:database]
    when "postgresql" then opt[:database] = "jdbcpostgresql"
    when "mysql"      then opt[:database] = "jdbcmysql"
    when "sqlite3"    then opt[:database] = "jdbcsqlite3"
    end
    self.options = opt.freeze
  end
end

#gem_for_database(database = options[:database]) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'railties/lib/rails/generators/database.rb', line 14

def gem_for_database(database = options[:database])
  case database
  when "mysql"          then ["mysql2", ["~> 0.5"]]
  when "postgresql"     then ["pg", ["~> 1.1"]]
  when "sqlite3"        then ["sqlite3", ["~> 1.4"]]
  when "oracle"         then ["activerecord-oracle_enhanced-adapter", nil]
  when "sqlserver"      then ["activerecord-sqlserver-adapter", nil]
  when "jdbcmysql"      then ["activerecord-jdbcmysql-adapter", nil]
  when "jdbcsqlite3"    then ["activerecord-jdbcsqlite3-adapter", nil]
  when "jdbcpostgresql" then ["activerecord-jdbcpostgresql-adapter", nil]
  when "jdbc"           then ["activerecord-jdbc-adapter", nil]
  else [database, nil]
  end
end

#initializeObject



9
10
11
12
# File 'railties/lib/rails/generators/database.rb', line 9

def initialize(*)
  super
  convert_database_option_for_jruby
end