db_tasks ========= Overview -------- Adds the following Rake tasks: rake db:create # Creates the databases defined in your config/database.yml (unless they already exist) You can also specify the charset and collation you want your dbs to use: rake db:create CHARSET='latin1' COLLATION='latin1_bin') rake db:drop # Drops the database for your currenet RAILS_ENV as defined in config/database.yml rake db:reset # Drops, creates and then migrates the database for your current RAILS_ENV rake db:shell # Launches the database shell using the values defined in config/database.yml rake db:charset # Returns the charset of your current RAILS_ENV database rake db:collation # Returns the collation of your current RAILS_ENV database rake db:update_connection_settings # add the encoding format to each environment in the database.yml file This plugin lets you easily create, drop and reset (drop, create, migrate) your databases just by editing your config/database.yml file and running one of the specific rake tasks such as rake db:reset This plugin also extends Rails to let you create databases with a defined character set and collation. By default, newly created databases will be UTF8. Notes ----- db:create and db:reset will create utf8 databases by default, you can overwrite the default collation and charset by specifying which ones you want to use: rake db:reset CHARSET='latin1' rake db:update_connection_settings will create a backup of your database.yml file. The new database.yml file won't have your old comments. For Rails to work properly with a utf8 database, it's recommended that you add encoding: utf8 to each environment of your database.yml file If you are using PostgreSQL, make sure to add its bin directory to your path Rails is "hot patched" and you can now do the following: MySQL adapter: Create a utf8 database (tables will inherit the charset and collation): ActiveRecord::Base.connection.create_database('my_utf8_db') Create a latin1 database (tables will inherit the charset and collation): ActiveRecord::Base.connection.create_database('charset_plugin_test', {:charset => 'latin1', :collation => 'latin1_bin'}) TODO (patched accepted): ------------------------ - rake task db:charset_switch to change the database charset/collation and all its tables Authors ------- Josh Knowles joshknowles@gmail.com Matt Heidemann matthew.heidemann@gmail.com Matt Aimonetti mattaimonetti@gmail.com http://railsresources.com Copyright (c) 2007 Integrum Technologies, LLC, released under the MIT license