-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rakefile
50 lines (36 loc) · 1016 Bytes
/
Rakefile
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
require 'active_support'
require 'active_record'
require 'jsi'
require_relative 'lib/qbot'
module ARConfig
include ActiveRecord::Tasks
def self.setup_env
class << QBot
attr_accessor :options
end
QBot.options = QBot::Options.new
QBot.init_log
QBot.init_config
QBot::Database.init_db
end
def self.db_config
QBot::Database.ar_config(QBot.config.database)
end
def self.setup
setup_env
DatabaseTasks.env = :development
DatabaseTasks.db_dir = File.join(__dir__, *%w[lib qbot db])
DatabaseTasks.root = __dir__
DatabaseTasks.migrations_paths = \
File.join(__dir__, *%w[lib qbot db migrate])
DatabaseTasks.database_configuration = { development: db_config }
DatabaseTasks.seed_loader = QBot::Database
ActiveRecord.suppress_multiple_database_warning = true
end
end
task :environment do
ActiveSupport.on_load(:before_initialize)
ARConfig.setup
end
load 'active_record/railties/databases.rake'