module PgTasks

Constants

DEFAULT_BINARY_DATA_FILE_NAME
DEFAULT_BINARY_STRUCTURE_AND_DATA_FILE_NAME
VERSION

Public Class Methods

terminate_connections() click to toggle source
# File lib/pg_tasks.rb, line 46
def terminate_connections
  ActiveRecord::Tasks::DatabaseTasks.terminate_connections current_config
end
truncate_tables() click to toggle source
# 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

Private Class Methods

current_config() click to toggle source
# File lib/pg_tasks.rb, line 52
def current_config
  ActiveRecord::Tasks::DatabaseTasks.current_config
end
filename_or_default_binary_data_file(filename) click to toggle source
# File lib/pg_tasks.rb, line 56
def filename_or_default_binary_data_file(filename)
  (filename.present? && filename) || \
    File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir,
              DEFAULT_BINARY_DATA_FILE_NAME)
end
filename_or_default_binary_structure_and_data_file(filename) click to toggle source
# File lib/pg_tasks.rb, line 62
def filename_or_default_binary_structure_and_data_file(filename)
  (filename.present? && filename) || \
    File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir,
              DEFAULT_BINARY_STRUCTURE_AND_DATA_FILE_NAME)
end