lib/nando/migrator.rb in nando-1.0.6 vs lib/nando/migrator.rb in nando-1.1.0

- old
+ new

@@ -54,10 +54,11 @@ # migrates all missing migrations def migrate (options = {}) _debug 'Migrating!' + migrations_to_apply = [] migration_files = get_migration_files(@migration_dir) if migration_files.length == 0 raise Nando::GenericError.new("No migration files were found in '#{@migration_dir}'") end @@ -71,10 +72,25 @@ if applied_migrations[migration_version] next end - execute_migration_method(:up, filename, migration_name, migration_version) + if options[:dry_run] + migrations_to_apply << {:migration_version => migration_version, :migration_name => migration_name} + else + execute_migration_method(:up, filename, migration_name, migration_version) + end + end + + if options[:dry_run] + if migrations_to_apply.count > 0 + puts "Migrations that would be applied:" + for migration in migrations_to_apply do + puts "=> #{migration[:migration_version]} - '#{migration[:migration_name]}'" + end + else + _warn 'No migration would be applied' + end end end # applies specific migration