提交 6404f8a1 编写于 作者: A Aaron Patterson

Merge pull request #1811 from nicksieger/more-jruby-gem-for-database-fixes-master

More jruby gem for database fixes master
...@@ -10,7 +10,7 @@ module Rails ...@@ -10,7 +10,7 @@ module Rails
module Generators module Generators
class AppBase < Base class AppBase < Base
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db ) DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql ) JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
DATABASES.concat(JDBC_DATABASES) DATABASES.concat(JDBC_DATABASES)
attr_accessor :rails_template attr_accessor :rails_template
...@@ -64,8 +64,8 @@ def self.add_shared_options_for(name) ...@@ -64,8 +64,8 @@ def self.add_shared_options_for(name)
def initialize(*args) def initialize(*args)
@original_wd = Dir.pwd @original_wd = Dir.pwd
super super
convert_database_option_for_jruby
end end
protected protected
...@@ -157,13 +157,25 @@ def gem_for_database ...@@ -157,13 +157,25 @@ def gem_for_database
when "postgresql" then "pg" when "postgresql" then "pg"
when "frontbase" then "ruby-frontbase" when "frontbase" then "ruby-frontbase"
when "mysql" then "mysql2" when "mysql" then "mysql2"
when "jdbcmysql" then "activerecord-jdbcmysql-adapter" when "jdbcmysql" then "activerecord-jdbcmysql-adapter"
when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter" when "jdbcsqlite3" then "activerecord-jdbcsqlite3-adapter"
when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter" when "jdbcpostgresql" then "activerecord-jdbcpostgresql-adapter"
when "jdbc" then "activerecord-jdbc-adapter"
else options[:database] else options[:database]
end end
end end
def convert_database_option_for_jruby
if defined?(JRUBY_VERSION)
case options[:database]
when "oracle" then options[:database].replace "jdbc"
when "postgresql" then options[:database].replace "jdbcpostgresql"
when "mysql" then options[:database].replace "jdbcmysql"
when "sqlite3" then options[:database].replace "jdbcsqlite3"
end
end
end
def ruby_debugger_gemfile_entry def ruby_debugger_gemfile_entry
if RUBY_VERSION < "1.9" if RUBY_VERSION < "1.9"
"gem 'ruby-debug'" "gem 'ruby-debug'"
......
# If you are using mssql, derby, hsqldb, or h2 with one of the
# ActiveRecord JDBC adapters, install the appropriate driver, e.g.,:
# gem install activerecord-jdbcmssql-adapter
#
# Configure using Gemfile:
# gem 'activerecord-jdbcmssql-adapter'
#
#development:
# adapter: mssql
# username: <%= app_name %>
# password:
# host: localhost
# database: <%= app_name %>_development
#
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
#
#test:
# adapter: mssql
# username: <%= app_name %>
# password:
# host: localhost
# database: <%= app_name %>_test
#
#production:
# adapter: mssql
# username: <%= app_name %>
# password:
# host: localhost
# database: <%= app_name %>_production
# If you are using oracle, db2, sybase, informix or prefer to use the plain
# JDBC adapter, configure your database setting as the example below (requires
# you to download and manually install the database vendor's JDBC driver .jar
# file). See your driver documentation for the apropriate driver class and
# connection string:
development:
adapter: jdbc
username: <%= app_name %>
password:
driver:
url: jdbc:db://localhost/<%= app_name %>_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: jdbc
username: <%= app_name %>
password:
driver:
url: jdbc:db://localhost/<%= app_name %>_test
production:
adapter: jdbc
username: <%= app_name %>
password:
driver:
url: jdbc:db://localhost/<%= app_name %>_production
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# And be sure to use new-style password hashing: # And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development: development:
adapter: jdbcmysql adapter: mysql
database: <%= app_name %>_development database: <%= app_name %>_development
username: root username: root
password: password:
...@@ -19,14 +19,14 @@ development: ...@@ -19,14 +19,14 @@ development:
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
adapter: jdbcmysql adapter: mysql
database: <%= app_name %>_test database: <%= app_name %>_test
username: root username: root
password: password:
host: localhost host: localhost
production: production:
adapter: jdbcmysql adapter: mysql
database: <%= app_name %>_production database: <%= app_name %>_production
username: root username: root
password: password:
......
# PostgreSQL. Versions 7.4 and 8.x are supported. # PostgreSQL. Versions 7.4 and 8.x are supported.
# #
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile # Configure Using Gemfile
# gem 'activerecord-jdbcpostgresql-adapter' # gem 'activerecord-jdbcpostgresql-adapter'
development: development:
adapter: jdbcpostgresql adapter: postgresql
encoding: unicode encoding: unicode
database: <%= app_name %>_development database: <%= app_name %>_development
username: <%= app_name %> username: <%= app_name %>
...@@ -38,14 +29,14 @@ development: ...@@ -38,14 +29,14 @@ development:
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
adapter: jdbcpostgresql adapter: postgresql
encoding: unicode encoding: unicode
database: <%= app_name %>_test database: <%= app_name %>_test
username: <%= app_name %> username: <%= app_name %>
password: password:
production: production:
adapter: jdbcpostgresql adapter: postgresql
encoding: unicode encoding: unicode
database: <%= app_name %>_production database: <%= app_name %>_production
username: <%= app_name %> username: <%= app_name %>
......
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
# gem 'activerecord-jdbcsqlite3-adapter' # gem 'activerecord-jdbcsqlite3-adapter'
# #
development: development:
adapter: jdbcsqlite3 adapter: sqlite3
database: db/development.sqlite3 database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
adapter: jdbcsqlite3 adapter: sqlite3
database: db/test.sqlite3 database: db/test.sqlite3
production: production:
adapter: jdbcsqlite3 adapter: sqlite3
database: db/production.sqlite3 database: db/production.sqlite3
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册