Module: Rails::Generators::Database
- Included in:
- AppBase, Rails::Generators::Db::System::ChangeGenerator
- Defined in:
- lib/rails/generators/database.rb
Overview
:nodoc:
Constant Summary collapse
- JDBC_DATABASES =
%w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
- DATABASES =
%w( mysql trilogy postgresql sqlite3 oracle sqlserver ) + JDBC_DATABASES
Instance Method Summary collapse
- #build_package_for_database(database = ) ⇒ Object
- #convert_database_option_for_jruby ⇒ Object
- #deploy_package_for_database(database = ) ⇒ Object
- #docker_for_database_build(database = ) ⇒ Object
- #docker_for_database_deploy(database = ) ⇒ Object
- #gem_for_database(database = options[:database]) ⇒ Object
- #initialize ⇒ Object
Instance Method Details
#build_package_for_database(database = ) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/rails/generators/database.rb', line 62 def build_package_for_database(database = [:database]) case database when "mysql" then "default-libmysqlclient-dev" when "postgresql" then "libpq-dev" else nil end end |
#convert_database_option_for_jruby ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rails/generators/database.rb', line 50 def convert_database_option_for_jruby if defined?(JRUBY_VERSION) opt = .dup case opt[:database] when "postgresql" then opt[:database] = "jdbcpostgresql" when "mysql" then opt[:database] = "jdbcmysql" when "sqlite3" then opt[:database] = "jdbcsqlite3" end self. = opt.freeze end end |
#deploy_package_for_database(database = ) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/rails/generators/database.rb', line 70 def deploy_package_for_database(database = [:database]) case database when "mysql" then "default-mysql-client" when "postgresql" then "postgresql-client" when "sqlite3" then "libsqlite3-0" else nil end end |
#docker_for_database_build(database = ) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rails/generators/database.rb', line 30 def docker_for_database_build(database = [:database]) case database when "mysql" then "build-essential default-libmysqlclient-dev git" when "trilogy" then "build-essential default-libmysqlclient-dev git" when "postgresql" then "build-essential git libpq-dev" when "sqlite3" then "build-essential git" else nil end end |
#docker_for_database_deploy(database = ) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/rails/generators/database.rb', line 40 def docker_for_database_deploy(database = [:database]) case database when "mysql" then "curl default-mysql-client libvips" when "trilogy" then "curl default-mysql-client libvips" when "postgresql" then "curl libvips postgresql-client" when "sqlite3" then "curl libsqlite3-0 libvips" else nil end end |
#gem_for_database(database = options[:database]) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails/generators/database.rb', line 14 def gem_for_database(database = [:database]) case database when "mysql" then ["mysql2", ["~> 0.5"]] when "trilogy" then ["trilogy", ["~> 2.4"]] 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 |
#initialize ⇒ Object
9 10 11 12 |
# File 'lib/rails/generators/database.rb', line 9 def initialize(*) super convert_database_option_for_jruby end |