Class: DatabaseCleaner::ActiveRecord::Seeded::Adapter::MYSQL

Inherits:
Object
  • Object
show all
Defined in:
lib/database_cleaner/active_record/seeded/adapter/mysql.rb

Constant Summary collapse

IGNORE_TABLES =
%w(schema_migrations)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seeds_file_path) ⇒ MYSQL

Returns a new instance of MYSQL.



17
18
19
# File 'lib/database_cleaner/active_record/seeded/adapter/mysql.rb', line 17

def initialize(seeds_file_path)
  @seeds_file_path = seeds_file_path
end

Instance Attribute Details

#seeds_file_pathObject (readonly)

Returns the value of attribute seeds_file_path.



15
16
17
# File 'lib/database_cleaner/active_record/seeded/adapter/mysql.rb', line 15

def seeds_file_path
  @seeds_file_path
end

Instance Method Details

#dump_database_to_fixtures_fileObject



25
26
27
# File 'lib/database_cleaner/active_record/seeded/adapter/mysql.rb', line 25

def dump_database_to_fixtures_file
  `mysqldump --user=#{user} --host=#{host} --port=#{port} --compact #{ignore_tables} --no-create-info=TRUE #{database} > #{seeds_file_path}`
end

#inject_seeds_from_fixtures_fileObject



21
22
23
# File 'lib/database_cleaner/active_record/seeded/adapter/mysql.rb', line 21

def inject_seeds_from_fixtures_file
  `mysql --user=#{user} --host=#{host} --port=#{port} --database=#{database} < #{seeds_file_path}`
end