From 6b192d29fa095e91cb40b71e76dfc811f4aa205c Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 9 Apr 2020 13:41:03 +1000 Subject: [PATCH] DEV: only enable SafeMigrate in development and test SafeMigrate outputs text when we detect attempts to unsafely drop tables and columns It is unfortunately not thread safe This is not needed in production as we would have already caught it by then in our test suite. --- lib/freedom_patches/safe_migrations.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/freedom_patches/safe_migrations.rb b/lib/freedom_patches/safe_migrations.rb index 718ffffb89..161d9fa8a7 100644 --- a/lib/freedom_patches/safe_migrations.rb +++ b/lib/freedom_patches/safe_migrations.rb @@ -2,4 +2,11 @@ require_dependency 'migration/safe_migrate' -Migration::SafeMigrate.patch_active_record! +# We do not run this in production cause it is intrusive and has +# potential to break stuff, it also breaks under concurrent use +# which rake:multisite_migrate uses +# +# The protection is only needed in Dev and Test +if ENV['RAILS_ENV'] != "production" + Migration::SafeMigrate.patch_active_record! +end