Created December 14, 2012 14:48
-
-
Save DevL/4285948 to your computer and use it in GitHub Desktop.
Revisions
-
DevL created this gist
Dec 14, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ namespace :generate do desc 'Generate a timestamped, empty Sequel migration.' task :migration, :name do |_, args| if args[:name].nil? puts 'You must specify a migration name (e.g. rake generate:migration[create_events])!' exit false end content = "Sequel.migration do\n up do\n \n end\n\n down do\n \n end\nend\n" timestamp = Time.now.to_i filename = File.join(File.dirname(__FILE__), 'migrations', "#{timestamp}_#{args[:name]}.rb") File.open(filename, 'w') do |f| f.puts content end puts "Created the migration #{filename}" end end