Sha256: 368dfe654200687c245346d7a62dcf07d734746c5e085514b26c47988d306db9

Contents?: true

Size: 605 Bytes

Versions: 4

Compression:

Stored size: 605 Bytes

Contents

require "sqlite3"
require "sequel"
require "singleton"

module Underway
  class DB
    include Singleton

    @@db = nil

    def self.configure(database_url)
      @@db = Sequel.connect(database_url)

      Sequel.default_timezone = :utc

      # TODO: extract to schema migration
      @@db.create_table?(:cached_tokens) do
        primary_key   :id
        Fixnum        :installation_id, null: false
        String        :token, null: false
        DateTime      :expires_at, null: false

        index [:installation_id, :expires_at]
      end
    end

    def database
      @@db
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
underway-2.0.0 lib/underway/database.rb
underway-1.1.0 lib/underway/database.rb
underway-1.0.1 lib/underway/database.rb
underway-1.0.0 lib/underway/database.rb