Sha256: 6c9e673fb1ce9b22c7dd5f2b1fe347d2187d2623ff787ed9c69b2b6a178a431c

Contents?: true

Size: 804 Bytes

Versions: 3

Compression:

Stored size: 804 Bytes

Contents

command 'db:migration:create' do
  description 'create migration patch'

  option '-m', '--path-to-migration-patches [DIR_PATH]', "set to check what directory should be used for db migrations (default: #{Rack::App::SeQueL::Migration::DEFAULT_DIRECTORY})" do |string|
    options[:migration_directory] = string
  end

  action do |*name_parts|
    options[:migration_directory] ||= Rack::App::SeQueL::Migration::DEFAULT_DIRECTORY
    name = name_parts.join('_')

    require 'fileutils'
    FileUtils.mkdir_p(options[:migration_directory])
    timestamp = Time.now.to_i
    filebasename = [timestamp.to_s, name].join('_') + '.rb'
    file_path = File.join(options[:migration_directory], filebasename)
    File.write(file_path, Rack::App::SeQueL::Migration::TEMPLATE)

    STDOUT.puts(file_path)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rack-app-sequel-0.6.0 lib/rack/app/sequel/migration/cli/template.rb
rack-app-sequel-0.5.0 lib/rack/app/sequel/migration/cli/template.rb
rack-app-sequel-0.4.0 lib/rack/app/sequel/migration/cli/template.rb