Sha256: ed4bb6114c39cc83833be83f48ac5fa57de290ba8bf6b1a071941eb5aee9827f

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

require_relative '../../models/team/activerecord.rb'

module SlackRubyBotServer
  module DatabaseAdapter
    def self.check!
      ActiveRecord::Base.connection_pool.with_connection(&:active?)
      raise 'Unexpected error.' unless ActiveRecord::Base.connected?
    rescue StandardError => e
      warn "Error connecting to PostgreSQL: #{e.message}"
      raise e
    end

    def self.init!
      return if ActiveRecord::Base.connection.tables.include?('teams')

      ActiveRecord::Base.connection.create_table :teams do |t|
        t.string :team_id
        t.string :name
        t.string :domain
        t.string :token
        t.string :oauth_scope
        t.string :oauth_version, default: 'v1', null: false
        t.string :bot_user_id
        t.string :activated_user_id
        t.string :activated_user_access_token
        t.boolean :active, default: true
        t.timestamps
      end
    end
  end
end

::Boolean = Grape::API::Boolean

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-bot-server-1.2.1 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-1.2.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb