module ChronoModel
  class Railtie < ::Rails::Railtie
    ActiveRecord::Tasks::DatabaseTasks.register_task /chronomodel/, ActiveRecord::Tasks::PostgreSQLDatabaseTasks

    setup = proc { ActiveRecord::Base.connection.chrono_setup! }

    rake_tasks do
      load 'chrono_model/schema_format.rake'

      namespace :db do
        namespace(:chrono) { task :model, &setup }
      end

      task 'db:schema:load' => 'db:chrono:model'
    end
  end
end

module ChronoModel
  class Railtie < ::Rails::Railtie
    ActiveRecord::Tasks::DatabaseTasks.register_task /chronomodel/, ActiveRecord::Tasks::PostgreSQLDatabaseTasks

    setup = lambda { ActiveRecord::Base.connection.chrono_setup }

    initializer :chrono_initialize, &setup

    rake_tasks do
      load 'chrono_model/schema_format.rake'

      namespace :db do
        namespace(:chrono) { task :model, &setup }
      end

      task 'db:schema:load' => 'db:chrono:model'
    end
  end
end

--- 
+++ 
@@ -2,9 +2,7 @@
   class Railtie < ::Rails::Railtie
     ActiveRecord::Tasks::DatabaseTasks.register_task /chronomodel/, ActiveRecord::Tasks::PostgreSQLDatabaseTasks
 
-    setup = lambda { ActiveRecord::Base.connection.chrono_setup }
-
-    initializer :chrono_initialize, &setup
+    setup = proc { ActiveRecord::Base.connection.chrono_setup! }
 
     rake_tasks do
       load 'chrono_model/schema_format.rake'
Remove Rails initializer, to follow Rails' behaviour :grinning:

The initializer would trigger a database connection and check for
needed upgrades. Rails currently does not have this behavior, and
it connects to the database when an ActiveRecord is referenced.

This change makes ChronoModel do its stuff when it is actually
requested, following Rails' behavior.
