Sha256: 07672545439499f0bde4796d591958cc27ab3ce6f9a624f51b72f02d34fb6e98

Contents?: true

Size: 761 Bytes

Versions: 8

Compression:

Stored size: 761 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.boolean :active, default: true
        t.timestamps
      end
    end
  end
end

::Boolean = Virtus::Attribute::Boolean

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
slack-ruby-bot-server-0.9.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.8.3 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.8.2 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.8.1 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.8.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.7.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.6.1 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb
slack-ruby-bot-server-0.6.0 lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb