Skip to content

Commit d8c547a

Browse files
Add migration_command accessor for overriding (#242)
With rails 6 multiple database support the `db:migrate` command isn't always what is needed when deploying to an environment. Other usecases are only running migrations for one of the databases using something like `db:migrate:primary`. Exposing the accessor `migration_command` allows flexibility for more scenarios.
1 parent 7d233fa commit d8c547a

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# [master][]
22

33
* Your contribution here!
4+
* Added option `:migration_command` to allow overriding the default `db:migrate` used.
45

56
# [1.5.0][] (May 15 2020)
67

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ set :migration_role, :db
6060
# Defaults to the primary :db server
6161
set :migration_servers, -> { primary(fetch(:migration_role)) }
6262

63+
# Defaults to `db:migrate`
64+
set :migration_command, 'db:migrate'
65+
6366
# Defaults to false
6467
# Skip migration if files in db/migrate were not modified
6568
set :conditionally_migrate, true

lib/capistrano/tasks/migrations.rake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace :deploy do
2222
on fetch(:migration_servers) do
2323
within release_path do
2424
with rails_env: fetch(:rails_env) do
25-
execute :rake, 'db:migrate'
25+
execute :rake, fetch(:migration_command)
2626
end
2727
end
2828
end
@@ -36,5 +36,6 @@ namespace :load do
3636
set :conditionally_migrate, fetch(:conditionally_migrate, false)
3737
set :migration_role, fetch(:migration_role, :db)
3838
set :migration_servers, -> { primary(fetch(:migration_role)) }
39+
set :migration_command, -> { fetch(:migration_command, 'db:migrate') }
3940
end
4041
end

0 commit comments

Comments
 (0)