Sha256: b362806a89cbdee2ed900bf18f05dc8d35cc6d11445fcdb70211c2a22dc0a644

Contents?: true

Size: 874 Bytes

Versions: 3

Compression:

Stored size: 874 Bytes

Contents

require 'slack-ruby-bot-server/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 :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 = Virtus::Attribute::Boolean

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.11.1 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.11.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.10.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb