Sha256: 00a8d50b6aa563dd0a99cee101842756750e80106b83609978cc2a775d15e929
Contents?: true
Size: 1.38 KB
Versions: 18
Compression:
Stored size: 1.38 KB
Contents
module SequelRails module Storage class Mysql < Abstract def _create execute "CREATE DATABASE IF NOT EXISTS `#{database}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}" end def _drop execute "DROP DATABASE IF EXISTS `#{database}`" end def _dump(filename) commands = ['mysqldump'] add_connection_settings commands add_flag commands, '--no-data' add_option commands, '--result-file', filename commands << database safe_exec commands end def _load(filename) commands = ['mysql'] add_connection_settings commands add_option commands, '--database', database add_option commands, '--execute', %(SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1) safe_exec commands end def collation @collation ||= super || 'utf8_unicode_ci' end private def add_connection_settings(commands) add_option commands, '--user', username add_option commands, '--password', password add_option commands, '--host', host add_option commands, '--port', port.to_s end def execute(statement) commands = ['mysql'] add_connection_settings commands add_option commands, '--execute', statement safe_exec commands end end end end
Version data entries
18 entries across 18 versions & 1 rubygems