提交 2cde98c8 编写于 作者: R Rafael Mendonça França

Merge pull request #11698 from dmathieu/sqlite_tasks_without_rails

Let the SQLite rake tasks run without rails
......@@ -46,6 +46,7 @@ class Railtie < Rails::Railtie # :nodoc:
ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration
ActiveRecord::Tasks::DatabaseTasks.migrations_paths = Rails.application.paths['db/migrate'].to_a
ActiveRecord::Tasks::DatabaseTasks.fixtures_path = File.join Rails.root, 'test', 'fixtures'
ActiveRecord::Tasks::DatabaseTasks.root = Rails.root
if defined?(ENGINE_PATH) && engine = Rails::Engine.find(ENGINE_PATH)
if engine.paths['db/migrate'].existent
......
......@@ -23,6 +23,7 @@ class DatabaseNotSupported < StandardError; end # :nodoc:
# * +fixtures_path+: a path to fixtures directory.
# * +migrations_paths+: a list of paths to directories with migrations.
# * +seed_loader+: an object which will load seeds, it needs to respond to the +load_seed+ method.
# * +root+: a path to the root of the application.
#
# Example usage of +DatabaseTasks+ outside Rails could look as such:
#
......@@ -37,7 +38,7 @@ module DatabaseTasks
attr_writer :current_config
attr_accessor :database_configuration, :migrations_paths, :seed_loader, :db_dir,
:fixtures_path, :env
:fixtures_path, :env, :root
LOCAL_HOSTS = ['127.0.0.1', 'localhost']
......
......@@ -3,7 +3,7 @@ module Tasks # :nodoc:
class SQLiteDatabaseTasks # :nodoc:
delegate :connection, :establish_connection, to: ActiveRecord::Base
def initialize(configuration, root = Rails.root)
def initialize(configuration, root = ActiveRecord::Tasks::DatabaseTasks.root)
@configuration, @root = configuration, root
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册