Last active
November 23, 2017 05:28
-
-
Save lhside/84d889d91eba6d9c73ee to your computer and use it in GitHub Desktop.
RakeでRidgepoleコマンドを実行する ref: https://qiita.com/lhside/items/0dcad79d9b801e34bc7c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle exec ridgepole --apply --file Schemafile --config config/database.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apply ridgepole schema | |
$ bundle exec rake ridgepole:apply | |
Export ridgepole schema | |
$ bundle exec rake ridgepole:export |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :ridgepole do | |
desc 'Apply database schema' | |
task apply: :environment do | |
ridgepole('--apply', "--file #{schema_file}") | |
Rake::Task['db:schema:dump'].invoke | |
end | |
desc 'Export database schema' | |
task export: :environment do | |
ridgepole('--export', "--output #{schema_file}") | |
end | |
private | |
def schema_file | |
Rails.root.join('Schemafile') | |
end | |
def config_file | |
Rails.root.join('config/database.yml') | |
end | |
def ridgepole(*options) | |
command = ['bundle exec ridgepole', "--config #{config_file}"] | |
system [command + options].join(' ') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment