|
10 | 10 | set :skip_data_sync_confirm, (ENV['SKIP_DATA_SYNC_CONFIRM'].to_s.downcase == 'true') |
11 | 11 | set :disallow_pushing, false unless fetch(:disallow_pushing) |
12 | 12 |
|
| 13 | +namespace :capistrano_db_tasks do |
| 14 | + task :check_can_push do |
| 15 | + raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing) |
| 16 | + end |
| 17 | +end |
| 18 | + |
13 | 19 | namespace :db do |
14 | 20 | namespace :remote do |
15 | 21 | desc 'Synchronize your remote database using local database data' |
16 | | - task :sync do |
| 22 | + task :sync => 'capistrano_db_tasks:check_can_push' do |
17 | 23 | on roles(:db) do |
18 | | - raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing) |
19 | 24 | if fetch(:skip_data_sync_confirm) || Util.prompt('Are you sure you want to REPLACE THE REMOTE DATABASE with local database') |
20 | 25 | Database.local_to_remote(self) |
21 | 26 | end |
|
45 | 50 | namespace :assets do |
46 | 51 | namespace :remote do |
47 | 52 | desc 'Synchronize your remote assets using local assets' |
48 | | - task :sync do |
| 53 | + task :sync => 'capistrano_db_tasks:check_can_push' do |
49 | 54 | on roles(:app) do |
50 | 55 | 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) |
52 | 56 | if fetch(:skip_data_sync_confirm) || Util.prompt("Are you sure you want to erase your server assets with local assets") |
53 | 57 | Asset.local_to_remote(self) |
54 | 58 | end |
|
78 | 82 | namespace :app do |
79 | 83 | namespace :remote do |
80 | 84 | desc 'Synchronize your remote assets AND database using local assets and database' |
81 | | - task :sync do |
82 | | - raise "pushing is disabled, set disallow_pushing to false to carry out this operation" if fetch(:disallow_pushing) |
| 85 | + task :sync => 'capistrano_db_tasks:check_can_push' do |
83 | 86 | 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)})") |
84 | 87 | on roles(:db) do |
85 | 88 | Database.local_to_remote(self) |
|
0 commit comments