Sha256: 7fd3f8235563cdffb9a97f255325201621538b7ee2a2c587c14854df72d8a4b4

Contents?: true

Size: 1.2 KB

Versions: 30

Compression:

Stored size: 1.2 KB

Contents

namespace :mysql do
  desc 'Build the MySQL test databases'
  task :build_databases => :load_connection do 
    puts File.join(SCHEMA_PATH, 'mysql.sql')
    options_str = ENV['cpk_adapter_options_str']
    # creates something like "-u#{username} -p#{password} -S#{socket}"
    sh %{ mysqladmin #{options_str} create "#{GEM_NAME}_unittest" }
    sh %{ mysql #{options_str} "#{GEM_NAME}_unittest" < #{File.join(SCHEMA_PATH, 'mysql.sql')} }
  end

  desc 'Drop the MySQL test databases'
  task :drop_databases => :load_connection do 
    options_str = ENV['cpk_adapter_options_str']
    sh %{ mysqladmin #{options_str} -f drop "#{GEM_NAME}_unittest" }
  end

  desc 'Rebuild the MySQL test databases'
  task :rebuild_databases => [:drop_databases, :build_databases]
  
  task :load_connection do
    require File.join(PROJECT_ROOT, %w[lib adapter_helper mysql])
    spec = AdapterHelper::MySQL.load_connection_from_env
    options = {}
    options['u'] = spec[:username]  if spec[:username]
    options['p'] = spec[:password]  if spec[:password]
    options['S'] = spec[:sock]      if spec[:sock]
    options_str = options.map { |key, value| "-#{key}#{value}" }.join(" ")
    ENV['cpk_adapter_options_str'] = options_str
  end
end

Version data entries

30 entries across 30 versions & 5 rubygems

Version Path
kovyrin-composite_primary_keys-2.3.2 tasks/databases/mysql.rake
mingusbabcock-composite_primary_keys-2.2.2.1 tasks/databases/mysql.rake
tyler-composite_primary_keys-1.1.0 tasks/databases/mysql.rake
tyler-composite_primary_keys-1.1.1 tasks/databases/mysql.rake
tyler-composite_primary_keys-1.1.2 tasks/databases/mysql.rake
tyler-composite_primary_keys-1.1.3 tasks/databases/mysql.rake
tyler-composite_primary_keys-1.1.4 tasks/databases/mysql.rake
globe-composite_primary_keys-3.0.1 tasks/databases/mysql.rake
composite_primary_keys-2.3.5.1 tasks/databases/mysql.rake
composite_primary_keys-2.3.5 tasks/databases/mysql.rake
composite_primary_keys-2.3.2 tasks/databases/mysql.rake
composite_primary_keys-1.0.3 tasks/databases/mysql.rake
composite_primary_keys-0.9.90 tasks/databases/mysql.rake
composite_primary_keys-1.0.10 tasks/databases/mysql.rake
composite_primary_keys-0.9.91 tasks/databases/mysql.rake
composite_primary_keys-0.9.92 tasks/databases/mysql.rake
composite_primary_keys-0.9.93 tasks/databases/mysql.rake
composite_primary_keys-1.0.0 tasks/databases/mysql.rake
composite_primary_keys-1.0.1 tasks/databases/mysql.rake
composite_primary_keys-1.0.2 tasks/databases/mysql.rake