Sha256: 19d0a3da1befa9052fdf4e50eecedb155c2188c9a2ce6a636809baef1dbdd6e5

Contents?: true

Size: 1007 Bytes

Versions: 3

Compression:

Stored size: 1007 Bytes

Contents

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

require 'pagy'
require 'pagy_cursor/pagy/extras/cursor'

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

3 entries across 3 versions & 1 rubygems

Version Path
slack-ruby-bot-server-2.1.1 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-2.1.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-2.0.1 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb