Sha256: 745e86e3cbaf6b6e591ee1020136c121c4baa865247e532c2c7ee9eac7811ad0

Contents?: true

Size: 862 Bytes

Versions: 7

Compression:

Stored size: 862 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 %app_name%_%environment%_db 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

7 entries across 7 versions & 1 rubygems

Version Path
uff_db_loader-2.1.0 lib/uff_db_loader/mysql.rb
uff_db_loader-2.0.1 lib/uff_db_loader/mysql.rb
uff_db_loader-2.0.0 lib/uff_db_loader/mysql.rb
uff_db_loader-1.4.0 lib/uff_db_loader/mysql.rb
uff_db_loader-1.3.0 lib/uff_db_loader/mysql.rb
uff_db_loader-1.2.0 lib/uff_db_loader/mysql.rb
uff_db_loader-1.1.1 lib/uff_db_loader/mysql.rb