Sha256: 3abc51fa27a34e0d64913c28f3b4479b5c4734711fb901f237057b1af83e57df

Contents?: true

Size: 860 Bytes

Versions: 6

Compression:

Stored size: 860 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 :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

6 entries across 6 versions & 1 rubygems

Version Path
slack-ruby-bot-server-1.1.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-1.0.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.12.3 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.12.2 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.12.1 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.12.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb