Sha256: 28a632fd6b78d52529fae5eb681bd8c70fa96d906b0e1eb8dde3deed5fb4e143
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
require "rails/railtie" module Multiverse class Railtie < Rails::Railtie generators do require "rails/generators/active_record/migration" ActiveRecord::Generators::Migration.prepend(Multiverse::Generators::Migration) require "rails/generators/active_record/model/model_generator" ActiveRecord::Generators::ModelGenerator.prepend(Multiverse::Generators::ModelGenerator) end rake_tasks do namespace :db do task :load_config do ActiveRecord::Tasks::DatabaseTasks.migrations_paths = [Multiverse.migrate_path] ActiveRecord::Tasks::DatabaseTasks.db_dir = [Multiverse.db_dir] end namespace :test do task load_schema: %w(db:test:purge) do begin should_reconnect = ActiveRecord::Base.connection_pool.active_connection? ActiveRecord::Schema.verbose = false ActiveRecord::Tasks::DatabaseTasks.load_schema ActiveRecord::Base.configurations[Multiverse.env("test")], :ruby, ENV["SCHEMA"] ensure if should_reconnect ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Multiverse.env(ActiveRecord::Tasks::DatabaseTasks.env)]) end end end task load_structure: %w(db:test:purge) do ActiveRecord::Tasks::DatabaseTasks.load_schema ActiveRecord::Base.configurations[Multiverse.env("test")], :sql, ENV["SCHEMA"] end task purge: %w(environment load_config check_protected_environments) do ActiveRecord::Tasks::DatabaseTasks.purge ActiveRecord::Base.configurations[Multiverse.env("test")] end end end namespace :multiverse do task :load_config do ActiveRecord::Base.establish_connection(Multiverse.record_class.connection_config) end end Rake::Task["db:migrate:status"].enhance ["multiverse:load_config"] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
multiverse-0.1.1 | lib/multiverse/railtie.rb |