Sha256: 2fd8ce1a2c27e2f050f65eca400f5819dc8dc5df45e522156e0cdf6ae3612450

Contents?: true

Size: 851 Bytes

Versions: 3

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

module UffDbLoader
  module Mysql
    def self.dump_extension
      "sql"
    end

    def self.dump_command_template
      "ssh %user%@%host% \"docker exec -i %container_name% sh -c 'exec mysqldump --opt --no-tablespaces -uroot -p\"\\$MYSQL_ROOT_PASSWORD\" %database%'\" > %target%"
    end

    def self.restore_command(database_name, result_file_path)
      "mysql -uroot #{database_name} < #{result_file_path}"
    end

    def self.list_databases
      ActiveRecord::Base.connection.execute("SHOW DATABASES;").to_a.flatten
    end

    def self.create_database(database_name)
      ActiveRecord::Base.connection.execute("CREATE DATABASE #{database_name};")
    end

    def self.drop_database(database_name)
      ActiveRecord::Base.connection.execute("DROP DATABASE IF EXISTS #{database_name};")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uff_db_loader-3.0.1 lib/uff_db_loader/mysql.rb
uff_db_loader-3.0.0 lib/uff_db_loader/mysql.rb
uff_db_loader-2.2.0 lib/uff_db_loader/mysql.rb