Sha256: 36c6325557f20658b693e59b2568e1658327dbce842e1b91d146a2ca203eb546
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require 'sequel' require 'ditty/services/logger' require 'active_support' require 'active_support/core_ext/object/blank' pool_timeout = (ENV['DB_POOL_TIMEOUT'] || 5).to_i if defined? DB ::Ditty::Services::Logger.warn 'Database connection already set up' elsif ENV['DATABASE_URL'].blank? == false # Delete DATABASE_URL from the environment, so it isn't accidently # passed to subprocesses. DATABASE_URL may contain passwords. DB = Sequel.connect( ENV['RACK_ENV'] == 'production' ? ENV.delete('DATABASE_URL') : ENV['DATABASE_URL'], pool_timeout: pool_timeout ) DB.sql_log_level = (ENV['SEQUEL_LOGGING_LEVEL'] || :debug).to_sym DB.loggers << ::Ditty::Services::Logger if ENV['DB_DEBUG'].to_i == 1 DB.extension(:pagination) DB.extension(:schema_caching) DB.load_schema_cache?('./config/schema.dump') Sequel::Model.plugin :auto_validations Sequel::Model.plugin :string_stripper Sequel::Model.plugin :timestamps, update_on_create: true Sequel::Model.plugin :update_or_create Sequel::Model.plugin :validation_helpers else ::Ditty::Services::Logger.error 'No database connection set up' end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ditty-0.10.2 | lib/ditty/db.rb |
ditty-0.10.1 | lib/ditty/db.rb |