Skip to content

Instantly share code, notes, and snippets.

@Ray-Hughes
Last active July 28, 2017 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ray-Hughes/cf79739de754c86a33bc34cf8f4b6207 to your computer and use it in GitHub Desktop.
Save Ray-Hughes/cf79739de754c86a33bc34cf8f4b6207 to your computer and use it in GitHub Desktop.
Sequel generate migration
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_contacts])!'
exit false
end
content = "Sequel.migration do\n up do\n \n end\n\n down do\n \n end\nend\n"
seq_next = get_next_seq
filename = File.join(File.dirname(__FILE__), 'migrations', "#{seq_next}_#{args[:name]}.rb")
File.open(filename, 'w') do |f|
f.puts content
end
puts "Created the migration #{filename}"
end
end
@gardwired
Copy link

is there a get_next_seq method somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment