File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed
Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Reverse Chronological Order:
77https://github.com/sgruhier/capistrano-db-tasks/compare/v0.6...HEAD
88
99* Your contribution here!
10+ * Add support for passing extra options to the database dump and load commands (@someonewithpc )
1011* Added support for [ zstd compressor] ( http://facebook.github.io/zstd/ ) (@ocha )
1112
1213# 0.6 (Dec 14 2016)
Original file line number Diff line number Diff line change @@ -72,18 +72,18 @@ def dump_cmd
7272
7373 def import_cmd ( file )
7474 if mysql?
75- "mysql #{ credentials } -D #{ database } < #{ file } "
75+ "mysql #{ credentials } -D #{ database } #{ import_cmd_opts } < #{ file } "
7676 elsif postgresql?
7777 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 } "
7979 end
8080 end
8181
8282 def dump_cmd_opts
8383 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 } "
8585 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 } "
8787 end
8888 end
8989
@@ -100,6 +100,18 @@ def dump_cmd_ignore_data_tables_opts
100100 ignore_tables = @cap . fetch ( :db_ignore_data_tables , [ ] )
101101 ignore_tables . map { |t | "--exclude-table-data=#{ t } " } . join ( " " ) if postgresql?
102102 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
103115 end
104116
105117 class Remote < Base
Original file line number Diff line number Diff line change 1414set :skip_data_sync_confirm , ENV [ 'SKIP_DATA_SYNC_CONFIRM' ] . to_s . casecmp ( 'true' ) . zero?
1515set :disallow_pushing , false unless fetch ( :disallow_pushing )
1616set :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 )
1719
1820namespace :capistrano_db_tasks do
1921 task :check_can_push do
Original file line number Diff line number Diff line change 11module CapistranoDbTasks
2- VERSION = "0.6 " . freeze
2+ VERSION = "0.7 " . freeze
33end
You can’t perform that action at this time.
0 commit comments