Permalink
Browse files

Merge pull request #319 from solzenic/patch-1

Fixed symfony:doctrine:schema:drop - added --force
  • Loading branch information...
2 parents ea7ba1f + b5aa7d0 commit c878e141d6b2a8d2e4fe251e34b4ee22e24edff9 @willdurand willdurand committed Jan 21, 2013
Showing with 22 additions and 14 deletions.
  1. +17 −12 lib/symfony2/doctrine.rb
  2. +4 −2 spec/capifony_symfony2_doctrine_spec.rb
  3. +1 −0 spec/spec_helper.rb
@@ -27,19 +27,22 @@
end
namespace :database do
- [:create, :drop].each do |action|
- desc "#{action.to_s.capitalize}s the configured databases"
- task action, :roles => :app, :except => { :no_release => true } do
- case action.to_s
- when "create"
- capifony_pretty_print "--> Creating databases"
- when "drop"
- capifony_pretty_print "--> Dropping databases"
- end
+ desc "Drops the configured databases"
+ task :drop, :roles => :app, :except => { :no_release => true } do
+ capifony_pretty_print "--> Dropping databases"
- run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:database:#{action.to_s} --env=#{symfony_env_prod}'", :once => true
- capifony_puts_ok
+ if !interactive_mode || Capistrano::CLI.ui.agree("Do you really want to drop #{symfony_env_prod}'s database? (y/N)")
+ run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:database:drop --force --env=#{symfony_env_prod}'", :once => true
end
+ capifony_puts_ok
+ end
+
+ desc "Creates the configured databases"
+ task :create, :roles => :app, :except => { :no_release => true } do
+ capifony_pretty_print "--> Creating databases"
+
+ run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:database:create --env=#{symfony_env_prod}'", :once => true
+ capifony_puts_ok
end
end
@@ -56,7 +59,9 @@
task :drop, :roles => :app, :except => { :no_release => true } do
capifony_pretty_print "--> Droping schema"
- run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:schema:drop --env=#{symfony_env_prod}'", :once => true
+ if !interactive_mode || Capistrano::CLI.ui.agree("Do you really want to drop #{symfony_env_prod}'s database schema? (y/N)")
+ run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:schema:drop --force --env=#{symfony_env_prod}'", :once => true
+ end
capifony_puts_ok
end
@@ -12,6 +12,8 @@
@configuration.set :try_sudo, ''
Capifony::Symfony2.load_into(@configuration)
+
+ @configuration.set :interactive_mode, false
end
subject { @configuration }
@@ -64,7 +66,7 @@
@configuration.find_and_execute_task('symfony:doctrine:database:drop')
end
- it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:database:drop --env=prod\'') }
+ it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:database:drop --force --env=prod\'') }
end
it "defines symfony:doctrine:schema tasks" do
@@ -86,7 +88,7 @@
@configuration.find_and_execute_task('symfony:doctrine:schema:drop')
end
- it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:schema:drop --env=prod\'') }
+ it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:schema:drop --force --env=prod\'') }
end
context "when running symfony:doctrine:schema:update" do
View
@@ -5,6 +5,7 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'capistrano-spec'
+require 'capistrano/cli'
require 'rspec'
require 'rspec/autorun'

0 comments on commit c878e14

Please sign in to comment.