Class: Hanami::CLI::Commands::App::DB::Utils::Mysql Private
- Defined in:
- lib/hanami/cli/commands/app/db/utils/mysql.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants inherited from Database
Database::DATABASE_CLASS_RESOLVER
Instance Attribute Summary
Attributes inherited from Database
#gateway_name, #slice, #system_call
Instance Method Summary collapse
- #exec_create_command ⇒ Object private
- #exec_drop_command ⇒ Object private
- #exec_dump_command ⇒ Object private
- #exec_load_command ⇒ Object private
- #exists? ⇒ Boolean private
Methods inherited from Database
#applied_migrations, #connection, database_class, #database_uri, #database_url, #db_config_dir?, #db_config_path, from_slice, #gateway, #initialize, #migrations_dir?, #migrations_path, #migrator, #name, #run_migrations, #schema_migrations_sql_dump, #sequel_migrator, #structure_file
Constructor Details
This class inherits a constructor from Hanami::CLI::Commands::App::DB::Utils::Database
Instance Method Details
#exec_create_command ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 17 18 |
# File 'lib/hanami/cli/commands/app/db/utils/mysql.rb', line 14 def exec_create_command return true if exists? exec_cli("mysql", %(-e "CREATE DATABASE #{escaped_name}")) end |
#exec_drop_command ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 |
# File 'lib/hanami/cli/commands/app/db/utils/mysql.rb', line 22 def exec_drop_command return true unless exists? exec_cli("mysql", %(-e "DROP DATABASE #{escaped_name}")) end |
#exec_dump_command ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 43 |
# File 'lib/hanami/cli/commands/app/db/utils/mysql.rb', line 38 def exec_dump_command exec_cli( "mysqldump", "--no-data --routines --skip-comments --result-file=#{structure_file} #{escaped_name}" ) end |
#exec_load_command ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 52 |
# File 'lib/hanami/cli/commands/app/db/utils/mysql.rb', line 47 def exec_load_command exec_cli( "mysql", %(--execute "SET FOREIGN_KEY_CHECKS = 0; SOURCE #{structure_file}; SET FOREIGN_KEY_CHECKS = 1" --database #{escaped_name}) ) end |
#exists? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 34 |
# File 'lib/hanami/cli/commands/app/db/utils/mysql.rb', line 30 def exists? result = exec_cli("mysql", %(-e "SHOW DATABASES LIKE '#{name}'" --batch)) result.successful? && result.out != "" end |