开发者

Rails 3 - Beta environment trying to create/migrate a blank database name

My app works on dev and I am trying to deploy it to a new slice. The environment is called 'beta'. Everything seems to be working okay except rake keeps trying to pass a blank '' database name, whether called in capistrano or manually. I would really appreciate any help as I'm not sure what to do next. Googling this has turned up nothing.

Thank you, Rabbit on Rails

ops@rws:~/sites/darkserve/current$ rake db:drop
(in /home/ops/sites/darkserve/releases/20110218183444)
Couldn't drop  : #<ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect database name '': DROP DATABASE IF EXISTS ``>

ops@rws:~/sites/darkserve/current$ rake db:create
(in /home/ops/sites/darkserve/releases/20110218183444)
 already exists

  * executing "cd /home/ops/sites/darkserve/releases/20110218183444; bundle exec rake RAILS_ENV=beta  db:migrate"
    servers: ["173.203.106.112"]
    [173.203.106.112:30000] executing command
*** [err :: 173.203.106.112:30000] rake aborted!
*** [err :: 173.203.106.112:30000] 
*** [err :: 173.203.106.112:30000] Mysql2::Error: No database selected: SHOW TABLES
*** [err :: 173.203.106.112:30000] 
*** [err :: 173.203.106.112:30000] 
*** [err :: 173.203.106.112:30000] (See full trace by running task with --trace)
*** [err :: 173.203.106.112:30000] 
 ** [out :: 173.203.106.112:30000] (in /home/ops/sites/darkserve/releases/20110218183444)

I have tried the obvious things like massaging my database.yml and beta.rb files, to no avail. Mysql works properly and the right user is created.

common: &mysql
  adapter: mysql2  
  host: localhost
  encoding: utf8
  username: root
  password: 
  pool: 5
  timeout: 5000
  reconnect: true

development:
  <<: *mysql
  database: darkserve_development

test:
  <<: *mysql
  database: darkserve_test

beta:
  <<: *mysql
  database: darkserve_beta

production:
  <<: *mysql
  database: darkserve_prod


ops@rws:~/sites/darkserve/current$ mysql -u root
Welcome to 开发者_高级运维the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 57
Server version: 5.1.41-3ubuntu12.9 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql> 




#beta.rb
Darkserve::Application.configure do
  # Settings specified here will take precedence over those in config/environment.rb

  # The production environment is meant for finished, "live" apps.
  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Specifies the header that your server uses for sending files
  config.action_dispatch.x_sendfile_header = "X-Sendfile"

  # For nginx:
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

  # If you have no front-end server that supports something like X-Sendfile,
  # just comment this out and Rails will serve the files

  # See everything in the log (default is :info)
  # config.log_level = :debug

  # Use a different logger for distributed setups
  # config.logger = SyslogLogger.new

  # Use a different cache store in production
  #config.cache_store = :mem_cache_store

  # Disable Rails's static asset server
  # In production, Apache or nginx will already do this
  config.serve_static_assets = false

  # Enable serving of images, stylesheets, and javascripts from an asset server
  # config.action_controller.asset_host = "http://assets.example.com"

  # Disable delivery errors, bad email addresses will be ignored
  # config.action_mailer.raise_delivery_errors = false
  config.action_mailer.delivery_method = :smtp

  # Enable threaded mode
  # config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify
end



ops@rws:~/sites/darkserve/current$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
ops@rws:~/sites/darkserve/current$ rails -v
Rails 3.0.4
ops@rws:~/sites/darkserve/current$ irb
ruby-1.9.2-p136 :001 > require 'mysql'
 => true 


I just switched to ruby 1.9 and discovered the same error. I think it is a bug from the YAML parser. It seems to fail to include the other keys when a reference is expanded.

Consider the following file: test.yml

common: &default
  user_name: 'test_user'

failed:
  <<: *default
  database: 'ignored db name'

success:
  user_name: 'test_user'
  database: 'db name'

Now look at what you get from the ruby prompt:

puts YAML.load_file('test.yml').inspect

{"common"=>{"user_name"=>"test_user"}, "failed"=>{"user_name"=>"test_user"}, 
 "success"=>{"user_name"=>"test_user", "database"=>"db name"}}

To fix this make sure that boot.rb selects 'syck', which I believe, has been around for a while.

require 'rubygems'

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'yaml'
YAML::ENGINE.yamler= 'syck'

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜