Skip to content

Instantly share code, notes, and snippets.

@DevL
Created December 14, 2012 14:48
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save DevL/4285948 to your computer and use it in GitHub Desktop.
Save DevL/4285948 to your computer and use it in GitHub Desktop.
Generate a timestamped, empty Sequel migration in the 'migrations' directory.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment