Module: PgTasks

Defined in:
lib/pg_tasks/version.rb,
lib/pg_tasks.rb,
lib/pg_tasks/railtie.rb

Overview

– Copyright © 2015 Thomas Schank

Released to the public under the terms of the MIT license. See MIT-LICENSE.

++

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

DEFAULT_BINARY_DATA_FILE_NAME =
'data.pgbin'
DEFAULT_BINARY_STRUCTURE_AND_DATA_FILE_NAME =
'structure_and_data.pgbin'
VERSION =
'1.3.3'

Class Method Summary collapse

Class Method Details

.terminate_connectionsObject



46
47
48
# File 'lib/pg_tasks.rb', line 46

def terminate_connections
  ActiveRecord::Tasks::DatabaseTasks.terminate_connections current_config
end

.truncate_tablesObject



37
38
39
40
41
42
43
44
# File 'lib/pg_tasks.rb', line 37

def truncate_tables
  ActiveRecord::Base.connection.tap do |connection|
    connection.tables.reject { |tn| tn == 'schema_migrations' }
      .join(', ').tap do |tables|
      connection.execute " TRUNCATE TABLE #{tables} CASCADE; "
    end
  end
end