Skip to content

Commit ae25656

Browse files
Add disallow_pushing to protect production from absentmindedness
1 parent 8afc3f5 commit ae25656

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Add to config/deploy.rb:
4343

4444
# if you want to work on a specific local environment (default = ENV['RAILS_ENV'] || 'development')
4545
set :locals_rails_env, "production"
46+
47+
# if you are highly paranoid and want to prevent any push operation to the server
48+
set :disallow_pushing, true
4649
```
4750

4851
Add to .gitignore

lib/capistrano-db-tasks/dbtasks.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
set :assets_dir, 'system' unless fetch(:assets_dir)
99
set :local_assets_dir, 'public' unless fetch(:local_assets_dir)
1010
set :skip_data_sync_confirm, (ENV['SKIP_DATA_SYNC_CONFIRM'].to_s.downcase == 'true')
11+
set :disallow_pushing, false unless fetch(:disallow_pushing)
1112

1213
namespace :db do
1314
namespace :remote do
1415
desc 'Synchronize your remote database using local database data'
1516
task :sync do
1617
on roles(:db) do
18+
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
1719
if fetch(:skip_data_sync_confirm) || Util.prompt('Are you sure you want to REPLACE THE REMOTE DATABASE with local database')
1820
Database.local_to_remote(self)
1921
end
@@ -46,6 +48,7 @@
4648
task :sync do
4749
on roles(:app) do
4850
puts "Assets directories: #{fetch(:assets_dir)}"
51+
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
4952
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to erase your server assets with local assets")
5053
Asset.local_to_remote(self)
5154
end
@@ -76,6 +79,7 @@
7679
namespace :remote do
7780
desc 'Synchronize your remote assets AND database using local assets and database'
7881
task :sync do
82+
raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing)
7983
if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to REPLACE THE REMOTE DATABASE AND your remote assets with local database and assets(#{fetch(:assets_dir)})")
8084
on roles(:db) do
8185
Database.local_to_remote(self)
@@ -110,4 +114,4 @@
110114

111115
desc 'Synchronize your remote assets AND database using local assets and database'
112116
task :push => "app:remote:sync"
113-
end
117+
end

0 commit comments

Comments
 (0)