-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathactiverecord.rb
More file actions
27 lines (24 loc) · 831 Bytes
/
activerecord.rb
File metadata and controls
27 lines (24 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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?(SlackRubyBotServer::Config.teams[:name].to_s)
ActiveRecord::Base.connection.create_table SlackRubyBotServer::Config.teams[:name] 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