Class: Bosh::AwsCliPlugin::Migrator
- Inherits:
-
Object
- Object
- Bosh::AwsCliPlugin::Migrator
- Defined in:
- lib/bosh_cli_plugin_aws/migrator.rb
Instance Method Summary collapse
- #environment_migrations ⇒ Object
-
#initialize(config) ⇒ Migrator
constructor
A new instance of Migrator.
- #migrate ⇒ Object
- #migrate_version(version) ⇒ Object
- #migrations ⇒ Object
- #needs_migration? ⇒ Boolean
- #pending_migrations ⇒ Object
Constructor Details
#initialize(config) ⇒ Migrator
Returns a new instance of Migrator.
5 6 7 8 |
# File 'lib/bosh_cli_plugin_aws/migrator.rb', line 5 def initialize(config) @config = config @migration_path = MigrationHelper.aws_migration_directory end |
Instance Method Details
#environment_migrations ⇒ Object
34 35 36 |
# File 'lib/bosh_cli_plugin_aws/migrator.rb', line 34 def environment_migrations @environment_migrations ||= load_migrations_for_env end |
#migrate ⇒ Object
10 11 12 13 14 |
# File 'lib/bosh_cli_plugin_aws/migrator.rb', line 10 def migrate return unless needs_migration? run_migrations(pending_migrations) end |
#migrate_version(version) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/bosh_cli_plugin_aws/migrator.rb', line 16 def migrate_version(version) return unless needs_migration? migration_to_run = pending_migrations.detect do |migration| migration.version == version.to_i end run_migrations([migration_to_run]) end |
#migrations ⇒ Object
30 31 32 |
# File 'lib/bosh_cli_plugin_aws/migrator.rb', line 30 def migrations @migrations ||= load_migrations end |
#needs_migration? ⇒ Boolean
38 39 40 41 |
# File 'lib/bosh_cli_plugin_aws/migrator.rb', line 38 def needs_migration? ensure_bucket_exists environment_migrations.nil? || environment_migrations != migrations end |
#pending_migrations ⇒ Object
26 27 28 |
# File 'lib/bosh_cli_plugin_aws/migrator.rb', line 26 def pending_migrations migrations - environment_migrations end |