feat(pg_type_map): add validation for Qx to run if database exists

This commit is contained in:
Luis Castro 2019-07-29 20:44:35 +02:00
parent da68bca689
commit 04a5eb039f
No known key found for this signature in database
GPG key ID: 0A8F33D4C4E27639

View file

@ -2,6 +2,12 @@
require 'active_record'
require 'qx'
require 'pg'
Qx.config(type_map: PG::BasicTypeMapForResults.new(ActiveRecord::Base.connection.raw_connection))
Qx.execute("SET TIME ZONE utc")
def database_exists?
ActiveRecord::Base.connection
rescue ActiveRecord::NoDatabaseError
false
else
Qx.config(type_map: PG::BasicTypeMapForResults.new(ActiveRecord::Base.connection.raw_connection))
Qx.execute("SET TIME ZONE utc")
end