Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 4c6bdf8a04254d25a70908298f55ed42b0c6a411 1 parent 64ba290
Paul Dowman authored
1  gem/lib/ec2onrails/recipes.rb
@@ -53,7 +53,6 @@
53 53
54 54 after "deploy:symlink", "ec2onrails:server:set_roles", "ec2onrails:server:init_services"
55 55 after "deploy:symlink", "ec2onrails:server:purge_proxy_cache"
56   - after "ec2onrails:db:create", "ec2onrails:db:init_backup"
57 56
58 57 on :load do
59 58 before "deploy:symlink", "ec2onrails:server:run_rails_rake_gems_install"
5 gem/lib/ec2onrails/recipes/db.rb
@@ -55,6 +55,9 @@
55 55 puts " * Pausing to give MySQL some time to start up..."
56 56 sleep 20
57 57
  58 + # TODO run init_backup after creating the db. This might be slow, so we need to
  59 + # check if the db exists, and exit without doing any of this if it exists.
  60 +
58 61 run %{mysql -u root -e "drop database if exists test; flush privileges;"}
59 62 # removing anonymous mysql accounts
60 63 run %{mysql -u root -D mysql -e "delete from db where User = ''; flush privileges;"}
@@ -65,7 +68,7 @@
65 68 run %{mysql -u root -e "create database if not exists \\`#{cfg[:db_name]}\\`;"}
66 69 run %{mysql -u root -e "grant all on \\`#{cfg[:db_name]}\\`.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
67 70 run %{mysql -u root -e "grant reload on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
68   - run %{mysql -u root -e "grant super on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
  71 + run %{mysql -u root -e "grant super on *.* to '#{cfg[:db_user]}'@'%' identified by '#{cfg[:db_password]}';"}
69 72 end
70 73
71 74 desc <<-DESC

0 comments on commit 4c6bdf8

Please sign in to comment.
Something went wrong with that request. Please try again.