Sha256: 50418f3cadc3a139944b243495a2a7b24dee91661dff77848db002ab16a2b05a
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
require 'tidy_reset/configuration' require 'tidy_reset/version' module TidyReset class << self attr_accessor :configuration def configuration @configuration ||= Configuration.new end def configure yield(configuration) end def execute(command) puts "running: #{command}" Bundler.with_clean_env do unless system(command) raise RuntimeError, "Error running last command. Return code was #{$?}" end end end def app_name(postfix) "#{configuration.app}-#{postfix}" end def database_purge(db_config) begin encoding = configuration.database_encoding master_connection = ActiveRecord::Base.establish_connection(db_config.merge( 'database' => 'postgres', 'schema_search_path' => 'public' )).connection master_connection.select_all("SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE datname='#{db_config['database']}' AND state='idle';") master_connection.drop_database(db_config['database']) master_connection.create_database(db_config['database'], db_config.merge('encoding' => encoding)) ActiveRecord::Base.establish_connection(db_config).connection.execute("CREATE EXTENSION IF NOT EXISTS postgis") rescue ActiveRecord::StatementInvalid => error if /database .* already exists/ === error.message raise DatabaseAlreadyExists else raise end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tidy_reset-0.1.2 | lib/tidy_reset.rb |
tidy_reset-0.1.1 | lib/tidy_reset.rb |