Skip to content

Commit

Permalink
Merge 12e3011 into 107ba07
Browse files Browse the repository at this point in the history
  • Loading branch information
yuh-pen authored Jul 4, 2018
2 parents 107ba07 + 12e3011 commit 8054894
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/generators/schemate/templates/schemate.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true
Schemate.configure do |config|
config.auto_generate = false
config.auto_generate_type = 'md'
end
2 changes: 2 additions & 0 deletions lib/schemate/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ def self.config
class Configuration
include ActiveSupport::Configurable
config_accessor :auto_generate
config_accessor :auto_generate_type
end

configure do |config|
config.auto_generate = false
config.auto_generate_type = 'md'
end
end
12 changes: 10 additions & 2 deletions lib/tasks/schemate_migrate.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ require "schemate/config"
namespace :db do
[:migrate, :rollback].each do |cmd|
task cmd do
Rake::Task['schemate:export_md'].invoke if Schemate.config.auto_generate
if Schemate.config.auto_generate_type == 'md'
Rake::Task['schemate:export_md'].invoke if Schemate.config.auto_generate
elsif Schemate.config.auto_generate_type == 'csv'
Rake::Task['schemate:export_csv'].invoke if Schemate.config.auto_generate
end
end

namespace cmd do
[:change, :up, :down, :reset, :redo].each do |t|
task t do
Rake::Task['schemate:export_md'].invoke if Schemate.config.auto_generate
if Schemate.config.auto_generate_type == 'md'
Rake::Task['schemate:export_md'].invoke if Schemate.config.auto_generate
elsif Schemate.config.auto_generate_type == 'csv'
Rake::Task['schemate:export_csv'].invoke if Schemate.config.auto_generate
end
end
end
end
Expand Down

0 comments on commit 8054894

Please sign in to comment.