DEV: always run migrations for plugins in dev

DEV: always run migrations for plugins in dev

Otherwise devs forget to run plugin migrations and get confused when test
does not work. We ship critical migrations in the bundled polls plugin.

From 6cf2e64e440a7d6b8b751c5965846ee3f9e494fd Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Thu, 6 Dec 2018 17:19:46 +1100
Subject: [PATCH] DEV: always run migrations for plugins in dev

Otherwise devs forget to run plugin migrations and get confused when test
does not work. We ship critical migrations in the bundled polls plugin.

diff --git a/bin/rake b/bin/rake
index 1724048..febc865 100755
--- a/bin/rake
+++ b/bin/rake
@@ -1,4 +1,12 @@
 #!/usr/bin/env ruby
+
+if ENV['RAILS_ENV'] == 'test' && ENV['LOAD_PLUGINS'].nil?
+  if ARGV.include?('db:migrate')
+    STDERR.puts "You are attempting to run migrations in your test environment and are not loading plugins, setting LOAD_PLUGINS to 1"
+    ENV['LOAD_PLUGINS'] = '1'
+  end
+end
+
 require_relative '../config/boot'
 require 'rake'
 Rake.application.run

GitHub

2 Likes