Sha256: 4c838d9b945f0867fd1760602c7dc65dc4aa3d2f8a0bfc86edaa98777c86b6c5

Contents?: true

Size: 881 Bytes

Versions: 3

Compression:

Stored size: 881 Bytes

Contents

module MysqlReplicationHelper
  module ErrorHandler
    def sql_to_recover_from(error)
      case (error)
      when /^Error 'Unknown database '([^\']+)'' on query/
        [
          "CREATE DATABASE `#{$1}`",
          "START SLAVE"
        ]
      when /^Error 'There is no '([^\']+)'@'([^\']+)' registered' on query. Default database: '([^\']+)'./
        [
          "CREATE USER `#{$1}`@`#{$2}`",
          "GRANT ALL PRIVILEGES ON `#{$3}`.* TO `#{$1}`@`#{$2}`",
          "START SLAVE"
        ]
      when /^Error 'View '[^\']+' references invalid table\(s\) or column\(s\) or function\(s\) or definer\/invoker of view lack rights to use them' on query. Default database: '([^\']+)'. Query: 'CREATE .*? DEFINER=`([^\`]+)`@`([^\`]+)`/
        [
          "GRANT ALL PRIVILEGES ON `#{$1}`.* TO `#{$2}`@`#{$3}`",
          "START SLAVE"
        ]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
theworkinggroup-mysql-replication-helper-0.1.0 lib/mysql_replication_helper/error_handler.rb
theworkinggroup-mysql-replication-helper-0.2.0 lib/mysql_replication_helper/error_handler.rb
mysql-replication-helper-0.2.1 lib/mysql_replication_helper/error_handler.rb