diff options
author | Antonio Cangiano <acangiano@gmail.com> | 2008-07-13 15:49:05 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-09-09 23:56:37 -0500 |
commit | 854cf3d7213a62792051b58032a3a9a1b2ebc45d (patch) | |
tree | 7db9c0d27a76767893894b129e8293fee7fb7a93 /railties | |
parent | 567392bff32acd5cf357565415d33c2662004cf5 (diff) | |
download | rails-854cf3d7213a62792051b58032a3a9a1b2ebc45d.tar.gz rails-854cf3d7213a62792051b58032a3a9a1b2ebc45d.tar.bz2 rails-854cf3d7213a62792051b58032a3a9a1b2ebc45d.zip |
Fix for SQLite's db creation warnings [status:committed #614]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/tasks/databases.rake | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 21c81b3fb5..cc079b1d93 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -28,8 +28,24 @@ namespace :db do def create_database(config) begin - ActiveRecord::Base.establish_connection(config) - ActiveRecord::Base.connection + if config['adapter'] =~ /sqlite/ + if File.exist?(config['database']) + $stderr.puts "#{config['database']} already exists" + else + begin + # Create the SQLite database + ActiveRecord::Base.establish_connection(config) + ActiveRecord::Base.connection + rescue + $stderr.puts $!, *($!.backtrace) + $stderr.puts "Couldn't create database for #{config.inspect}" + end + end + return # Skip the else clause of begin/rescue + else + ActiveRecord::Base.establish_connection(config) + ActiveRecord::Base.connection + end rescue case config['adapter'] when 'mysql' @@ -52,10 +68,6 @@ namespace :db do $stderr.puts $!, *($!.backtrace) $stderr.puts "Couldn't create database for #{config.inspect}" end - when 'sqlite' - `sqlite "#{config['database']}"` - when 'sqlite3' - `sqlite3 "#{config['database']}"` end else $stderr.puts "#{config['database']} already exists" |