Class: Lotus::Generators::Migration Private

Inherits:
Abstract
  • Object
show all
Defined in:
lib/lotus/generators/migration.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

Constant Summary collapse

TIMESTAMP_FORMAT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Examples:

20150612160502

Since:

  • 0.4.0

'%Y%m%d%H%M%S'.freeze
FILENAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Examples:

20150612160502_create_books.rb

Since:

  • 0.4.0

'%{timestamp}_%{name}.rb'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Migration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Migration.

Since:

  • 0.4.0



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lotus/generators/migration.rb', line 25

def initialize(command)
  super

  timestamp = Time.now.utc.strftime(TIMESTAMP_FORMAT)
  filename  = FILENAME % { timestamp: timestamp, name: name }

  env.require_application_environment
  @destination = Lotus::Model.configuration.migrations.join(filename)

  cli.class.source_root(source)
end

Instance Method Details

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



39
40
41
42
43
44
45
46
47
# File 'lib/lotus/generators/migration.rb', line 39

def start
  templates = {
    'migration.rb.tt' => @destination
  }

  templates.each do |src, dst|
    cli.template(source.join(src), target.join(dst), {})
  end
end