Class: Jets::Commands::Db::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/commands/db/tasks.rb

Class Method Summary collapse

Class Method Details

.load!Object

Ugly but it loads ActiveRecord database tasks



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/jets/commands/db/tasks.rb', line 7

def self.load!
  # Jets.boot # Jets.boot here screws up jets -h, the db_config doesnt seem to match exactly
  # but seems to be working anyway.
  db_configs = Jets.application.config.database
  ActiveRecord::Tasks::DatabaseTasks.database_configuration = db_configs
  ActiveRecord::Tasks::DatabaseTasks.migrations_paths = ["db/migrate"]

  # Need to mock out the usage of Rails.application in:
  # activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb
  Rails.application = RecursiveOpenStruct.new(
    config: {
      paths: {
        db: ["db"],
      }
    },
    paths: {
      "db/migrate": ["db/migrate"]
    }
  )
  load "active_record/railties/databases.rake"

  load File.expand_path("../environment-task.rake", __FILE__)
end