File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Reverse Chronological Order:
7
7
https://github.com/sgruhier/capistrano-db-tasks/compare/v0.6...HEAD
8
8
9
9
* Your contribution here!
10
+ * Add support for passing extra options to the database dump and load commands (@someonewithpc )
10
11
* Added support for [ zstd compressor] ( http://facebook.github.io/zstd/ ) (@ocha )
11
12
12
13
# 0.6 (Dec 14 2016)
Original file line number Diff line number Diff line change @@ -72,18 +72,18 @@ def dump_cmd
72
72
73
73
def import_cmd ( file )
74
74
if mysql?
75
- "mysql #{ credentials } -D #{ database } < #{ file } "
75
+ "mysql #{ credentials } -D #{ database } #{ import_cmd_opts } < #{ file } "
76
76
elsif postgresql?
77
77
terminate_connection_sql = "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '#{ database } ' AND pid <> pg_backend_pid();"
78
- "#{ pgpass } psql -c \" #{ terminate_connection_sql } ;\" #{ credentials } #{ database } ; #{ pgpass } dropdb #{ credentials } #{ database } ; #{ pgpass } createdb #{ credentials } #{ database } ; #{ pgpass } psql #{ credentials } -d #{ database } < #{ file } "
78
+ "#{ pgpass } psql -c \" #{ terminate_connection_sql } ;\" #{ credentials } #{ database } ; #{ pgpass } dropdb #{ credentials } #{ database } ; #{ pgpass } createdb #{ credentials } #{ database } ; #{ pgpass } psql #{ credentials } -d #{ database } #{ import_cmd_opts } < #{ file } "
79
79
end
80
80
end
81
81
82
82
def dump_cmd_opts
83
83
if mysql?
84
- "--lock-tables=false #{ dump_cmd_ignore_tables_opts } #{ dump_cmd_ignore_data_tables_opts } "
84
+ "--lock-tables=false #{ dump_cmd_ignore_tables_opts } #{ dump_cmd_ignore_data_tables_opts } #{ dump_cmd_extra_opts } "
85
85
elsif postgresql?
86
- "--no-acl --no-owner #{ dump_cmd_ignore_tables_opts } #{ dump_cmd_ignore_data_tables_opts } "
86
+ "--no-acl --no-owner #{ dump_cmd_ignore_tables_opts } #{ dump_cmd_ignore_data_tables_opts } #{ dump_cmd_extra_opts } "
87
87
end
88
88
end
89
89
@@ -100,6 +100,18 @@ def dump_cmd_ignore_data_tables_opts
100
100
ignore_tables = @cap . fetch ( :db_ignore_data_tables , [ ] )
101
101
ignore_tables . map { |t | "--exclude-table-data=#{ t } " } . join ( " " ) if postgresql?
102
102
end
103
+
104
+ def dump_cmd_extra_opts
105
+ @cap . fetch ( :db_dump_extra_opts , "" )
106
+ end
107
+
108
+ def import_cmd_opts
109
+ import_cmd_extra_opts
110
+ end
111
+
112
+ def import_cmd_extra_opts
113
+ @cap . fetch ( :db_import_extra_opts , "" )
114
+ end
103
115
end
104
116
105
117
class Remote < Base
Original file line number Diff line number Diff line change 14
14
set :skip_data_sync_confirm , ENV [ 'SKIP_DATA_SYNC_CONFIRM' ] . to_s . casecmp ( 'true' ) . zero?
15
15
set :disallow_pushing , false unless fetch ( :disallow_pushing )
16
16
set :compressor , :gzip unless fetch ( :compressor )
17
+ set :db_dump_extra_opts , '' unless fetch ( :db_dump_extra_opts )
18
+ set :db_import_extra_opts , '' unless fetch ( :db_import_extra_opts )
17
19
18
20
namespace :capistrano_db_tasks do
19
21
task :check_can_push do
You can’t perform that action at this time.
0 commit comments