Sha256: 9330854e07ca3f3d2dc92309586f903f070c76cffe66d5c0f44a4496a7cef102

Contents?: true

Size: 1.22 KB

Versions: 62

Compression:

Stored size: 1.22 KB

Contents

require 'arjdbc/tasks/jdbc_database_tasks'

module ArJdbc
  module Tasks
    class MSSQLDatabaseTasks < JdbcDatabaseTasks

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

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

      def structure_load(filename)
        config = config_from_url_if_needed
        `sqlcmd -S #{config['host']} -d #{config['database']} -U #{config['username']} -P #{config['password']} -i #{filename}`
      end

      private

      def config_from_url_if_needed
        config = self.config
        if config['url'] && ! config.key?('database')
          config = config_from_url(config['url'])
        end
        config
      end

      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

62 entries across 62 versions & 3 rubygems

Version Path
activerecord-jdbc-adapter-70.2-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-61.3-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-70.1-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-70.0-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-70.0.pre-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-61.2-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-61.1-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-60.4-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-52.8-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-61.0-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-60.3-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-52.7-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-51.8-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-50.8-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-60.2-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-52.6-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-51.7-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-50.7-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-60.1-java lib/arjdbc/tasks/mssql_database_tasks.rb
activerecord-jdbc-adapter-52.5-java lib/arjdbc/tasks/mssql_database_tasks.rb