Sha256: 63cac6af241fe6bc870b6c7f314f0557900b09f5f03371308800c49e41b70364

Contents?: true

Size: 967 Bytes

Versions: 9

Compression:

Stored size: 967 Bytes

Contents

require 'arjdbc/tasks/jdbc_database_tasks'

module ArJdbc
  module Tasks
    class MSSQLDatabaseTasks < JdbcDatabaseTasks

      def purge
        test = deep_dup(configuration)
        test_database = test['database']
        test['database'] = 'master'
        establish_connection(test)
        connection.recreate_database!(test_database)
      end

      def structure_dump(filename)
        `smoscript -s #{config['host']} -d #{config['database']} -u #{config['username']} -p #{config['password']} -f #{filename} -A -U`
      end

      def structure_load(filename)
        `sqlcmd -S #{config['host']} -d #{config['database']} -U #{config['username']} -P #{config['password']} -i #{filename}`
      end
      
      private
      
      def deep_dup(hash)
        dup = hash.dup
        dup.each_pair do |k,v|
          tv = dup[k]
          dup[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? deep_dup(tv) : v
        end
        dup
      end
      
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.6 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.5 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.4 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.3 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.2 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.1 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.0 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.0.rc1 lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-1.3.0.beta2 lib/arjdbc/tasks/mssql_database_tasks.rb