lib/ardb/runner/migrate_command.rb in ardb-0.20.0 vs lib/ardb/runner/migrate_command.rb in ardb-0.21.0

- old
+ new

@@ -3,15 +3,15 @@ require 'ardb/runner' require 'ardb/migration_helpers' class Ardb::Runner::MigrateCommand - attr_reader :migrations_path, :schema_file_path, :version, :verbose + attr_reader :migrations_path, :version, :verbose def initialize + @adapter = Ardb::Adapter.send(Ardb.config.db.adapter) @migrations_path = Ardb.config.migrations_path - @schema_file_path = Ardb.config.schema_path @version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil @verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true end def run @@ -27,22 +27,20 @@ end end def migrate_the_db if defined?(ActiveRecord::Migration::CommandRecorder) - ActiveRecord::Migration::CommandRecorder.send(:include, Ardb::MigrationHelpers::RecorderMixin) + ActiveRecord::Migration::CommandRecorder.class_eval do + include Ardb::MigrationHelpers::RecorderMixin + end end ActiveRecord::Migrator.migrations_path = @migrations_path ActiveRecord::Migration.verbose = @verbose ActiveRecord::Migrator.migrate(@migrations_path, @version) do |migration| ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope) end - require 'active_record/schema_dumper' - FileUtils.mkdir_p File.dirname(@schema_file_path) - File.open(@schema_file_path, "w:utf-8") do |file| - ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file) - end + @adapter.dump_schema end end