public
Fork of NZKoz/koz-rails
Description: Koz's rails git-svn clone
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/eventualbuddha/koz-rails.git
Search Repo:
Fix database rake tasks to work with charset/collation and show proper 
error messages on failure. Closes #11301 [matt]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9004 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
pratik (author)
Mon Mar 10 04:42:01 -0700 2008
commit  323c95914de735a2a487d59c01e48dc635b1308d
tree    0b979d7e382e171c1688c7c841b299ea0830d78d
parent  611565a55951bb7eaca0351b0aa22c395cb62981
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Fix database rake tasks to work with charset/collation and show proper error messages on failure. Closes #11301 [matt]
0
+
0
 * add a -e/--export to script/plugin install, uses svn export. #10847 [jon@blankpad.net)]
0
 
0
 * Add config.time_zone for configuring the default Time.zone value. #10982 [Geoff Buesing]
...
37
38
39
40
 
41
42
43
 
44
45
46
...
68
69
70
71
 
 
 
 
 
 
72
73
74
...
37
38
39
 
40
41
42
 
43
44
45
46
...
68
69
70
 
71
72
73
74
75
76
77
78
79
0
@@ -37,10 +37,10 @@
0
         @collation = ENV['COLLATION'] || 'utf8_general_ci'
0
         begin
0
           ActiveRecord::Base.establish_connection(config.merge({'database' => nil}))
0
- ActiveRecord::Base.connection.create_database(config['database'], {:charset => @charset, :collation => @collation})
0
+ ActiveRecord::Base.connection.create_database(config['database'], {:charset => (config['database']['charset'] || @charset), :collation => (config['database']['charset'] || @collation)})
0
           ActiveRecord::Base.establish_connection(config)
0
         rescue
0
- $stderr.puts "Couldn't create database for #{config.inspect}"
0
+ $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{@charset}, collation: #{@collation} (if you set the charset manually, make sure you have a matching collation)"
0
         end
0
       when 'postgresql'
0
         `createdb "#{config['database']}" -E utf8`
0
@@ -68,7 +68,12 @@
0
 
0
   desc 'Drops the database for the current RAILS_ENV'
0
   task :drop => :environment do
0
- drop_database(ActiveRecord::Base.configurations[RAILS_ENV || 'development'])
0
+ config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
0
+ begin
0
+ drop_database(config)
0
+ rescue Exception => e
0
+ puts "Couldn't drop #{config['database']} : #{e.inspect}"
0
+ end
0
   end
0
 
0
   def local_database?(config, &block)

Comments

    No one has commented yet.