Sha256: 1ead83f5daad2acd13e3560030675af114fd0bb58c3b8555ee40727395b83393

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

# frozen_string_literal: true

require 'sequel'
require 'ditty/services/logger'

if ENV['DATABASE_URL']
  # 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'])

  DB.sql_log_level = (ENV['SEQUEL_LOGGING_LEVEL'] || :debug).to_sym
  DB.loggers << Ditty::Services::Logger.instance
  DB.extension(:pagination)

  Sequel::Model.plugin :validation_helpers
  Sequel::Model.plugin :update_or_create
  Sequel::Model.plugin :timestamps, update_on_create: true
else
  Ditty::Services::Logger.instance.error 'No database connection set up'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ditty-0.3.2 lib/ditty/db.rb
ditty-0.3.1 lib/ditty/db.rb