Class: FluentMigratorCommandRunner::MigrationCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent-migrator-command-runner/commands/migration_command.rb

Constant Summary collapse

PARAMETER_PREFIX =
'--'
SPACE_CHAR =
"\s"
MIGRATOR_DELIMITER =
"#{SPACE_CHAR + PARAMETER_PREFIX}"
CONNECTION_STRING_DELIMITER =
';'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ MigrationCommand

Returns a new instance of MigrationCommand.



16
17
18
19
20
21
22
23
24
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 16

def initialize(options = {})
			@profile = options[:profile] unless options[:profile].nil?
			@tag = options[:tag] unless options[:tag].nil?
			@provider = FigNewton.migration_provider('oracle')
			@path_to_migrator = FigNewton.path_to_migrator_exe
			@path_to_migration_assembly = FigNewton.path_to_migration_assembly
			@connection_information = FigNewton.database.to_hash
			@connection_information['password'] = options[:db_password] unless options[:db_password].nil?
end

Instance Attribute Details

#connection_informationObject (readonly)

Returns the value of attribute connection_information.



3
4
5
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 3

def connection_information
  @connection_information
end

#path_to_migration_assemblyObject (readonly)

Returns the value of attribute path_to_migration_assembly.



3
4
5
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 3

def path_to_migration_assembly
  @path_to_migration_assembly
end

#path_to_migratorObject (readonly)

Returns the value of attribute path_to_migrator.



3
4
5
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 3

def path_to_migrator
  @path_to_migrator
end

#profileObject (readonly)

Returns the value of attribute profile.



3
4
5
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 3

def profile
  @profile
end

#providerObject (readonly)

Returns the value of attribute provider.



3
4
5
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 3

def provider
  @provider
end

#tagObject (readonly)

Returns the value of attribute tag.



3
4
5
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 3

def tag
  @tag
end

Instance Method Details

#buildObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fluent-migrator-command-runner/commands/migration_command.rb', line 26

def build
	connection_string = build_connection_string(@connection_information)

	command_sections = []
	command_sections.push(@path_to_migrator)
	command_sections.push("provider #{@provider}")
	command_sections.push("conn \"#{connection_string}\"")
	command_sections.push('task migrate')
	command_sections.push("assembly \"#{@path_to_migration_assembly}\"")
	command_sections.push("tag #{@tag}") if @tag
	command_sections.push("profile=#{@profile}") if @profile
	command_sections.join(MIGRATOR_DELIMITER)
end