Sha256: ee5ab9d8b524555c047c1d477628abf693eeba97b9e123fd23d01a3e2b95a05a
Contents?: true
Size: 1.05 KB
Versions: 26
Compression:
Stored size: 1.05 KB
Contents
module ActiveRecord module MigrationChecker def prepare_test_db current_config = ::ActiveRecord::Base.connection_config all_configs = ::ActiveRecord::Base.configurations.configs_for(env_name: Jets.env) needs_update = !all_configs.all? do |db_config| ::ActiveRecord::Tasks::DatabaseTasks.schema_up_to_date?(db_config.config, ::ActiveRecord::Base.schema_format, nil, Jets.env, db_config.spec_name) end if needs_update # Roundtrip to Rake to allow plugins to hook into database initialization. FileUtils.cd(Jets.root) do ::ActiveRecord::Base.clear_all_connections! system("jets db:test:prepare") end end # Establish a new connection, the old database may be gone (db:test:prepare uses purge) ::ActiveRecord::Base.establish_connection(current_config) begin check_pending! rescue ::ActiveRecord::PendingMigrationError puts "Migrations are pending. To resolve this issue, run:\n\n jets db:migrate" exit 1 end end end end
Version data entries
26 entries across 26 versions & 1 rubygems