Browse files

Don't do init_backup every time db:create is run because it might be …

…slow if there is a large database that already exists. This matters especially after changing the running instances (e.g. adding more app servers) because when you do ec2onrails:setup it will run db:create (harmless) on the existing db.

Added a TODO in create_database to do the backup then, but first we need to check for the existence of the db and exit if it exists.
  • Loading branch information...
1 parent 64ba290 commit 4c6bdf8a04254d25a70908298f55ed42b0c6a411 @pauldowman committed Oct 22, 2009
Showing with 4 additions and 2 deletions.
  1. +0 −1 gem/lib/ec2onrails/recipes.rb
  2. +4 −1 gem/lib/ec2onrails/recipes/db.rb
1 gem/lib/ec2onrails/recipes.rb
@@ -53,7 +53,6 @@
after "deploy:symlink", "ec2onrails:server:set_roles", "ec2onrails:server:init_services"
after "deploy:symlink", "ec2onrails:server:purge_proxy_cache"
- after "ec2onrails:db:create", "ec2onrails:db:init_backup"
on :load do
before "deploy:symlink", "ec2onrails:server:run_rails_rake_gems_install"
5 gem/lib/ec2onrails/recipes/db.rb
@@ -55,6 +55,9 @@
puts " * Pausing to give MySQL some time to start up..."
sleep 20
+ # TODO run init_backup after creating the db. This might be slow, so we need to
+ # check if the db exists, and exit without doing any of this if it exists.
run %{mysql -u root -e "drop database if exists test; flush privileges;"}
# removing anonymous mysql accounts
run %{mysql -u root -D mysql -e "delete from db where User = ''; flush privileges;"}
@@ -65,7 +68,7 @@
run %{mysql -u root -e "create database if not exists \\`#{cfg[:db_name]}\\`;"}
run %{mysql -u root -e "grant all on \\`#{cfg[:db_name]}\\`.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
run %{mysql -u root -e "grant reload on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
- run %{mysql -u root -e "grant super on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
+ run %{mysql -u root -e "grant super on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
desc <<-DESC

0 comments on commit 4c6bdf8

Please sign in to comment.