Module: Rails::Generators::Database
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | railties/lib/rails/generators/database.rb |
Constant Summary
-
DATABASES =
# File 'railties/lib/rails/generators/database.rb', line 7%w( mysql trilogy postgresql sqlite3 oracle sqlserver ) + JDBC_DATABASES
-
JDBC_DATABASES =
# File 'railties/lib/rails/generators/database.rb', line 6%w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
Instance Method Summary
- #base_package_for_database(database = )
- #build_package_for_database(database = )
- #convert_database_option_for_jruby
- #docker_for_database_base(database = )
- #docker_for_database_build(database = )
- #gem_for_database(database = options[:database])
- #initialize
- #mysql_database_host private
- #mysql_socket private
Instance Method Details
#base_package_for_database(database = )
[ GitHub ]# File 'railties/lib/rails/generators/database.rb', line 62
def base_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
#build_package_for_database(database = )
[ GitHub ]# File 'railties/lib/rails/generators/database.rb', line 71
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
[ GitHub ]# File 'railties/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
#docker_for_database_base(database = )
[ GitHub ]# File 'railties/lib/rails/generators/database.rb', line 30
def docker_for_database_base(database = [:database]) case database when "mysql" then "curl default-mysql-client libvips" when "trilogy" then "curl libvips" when "postgresql" then "curl libvips postgresql-client" when "sqlite3" then "curl libsqlite3-0 libvips" else nil end end
#docker_for_database_build(database = )
[ GitHub ]# File 'railties/lib/rails/generators/database.rb', line 40
def docker_for_database_build(database = [:database]) case database when "mysql" then "build-essential default-libmysqlclient-dev git" when "trilogy" then "build-essential git" when "postgresql" then "build-essential git libpq-dev" when "sqlite3" then "build-essential git" else nil end end
#gem_for_database(database = options[:database])
[ GitHub ]# File 'railties/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.7"]] 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
[ GitHub ]# File 'railties/lib/rails/generators/database.rb', line 9
def initialize(*) super convert_database_option_for_jruby end
#mysql_database_host (private)
[ GitHub ]# File 'railties/lib/rails/generators/database.rb', line 94
def mysql_database_host if [:skip_devcontainer] "localhost" else "<%= ENV.fetch(\"DB_HOST\") { \"localhost\" } %>" end end
#mysql_socket (private)
[ GitHub ]# File 'railties/lib/rails/generators/database.rb', line 80
def mysql_socket @mysql_socket ||= [ "/tmp/mysql.sock", # default "/var/run/mysqld/mysqld.sock", # debian/gentoo "/var/tmp/mysql.sock", # freebsd "/var/lib/mysql/mysql.sock", # fedora "/opt/local/lib/mysql/mysql.sock", # fedora "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4 "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5 "/opt/lampp/var/mysql/mysql.sock" # xampp for linux ].find { |f| File.exist?(f) } unless Gem.win_platform? end