From 8f5cf8cd2dba33cc42dcc3f0379414f3199decec Mon Sep 17 00:00:00 2001 From: Chris Arcand Date: Wed, 11 Oct 2017 10:27:34 -0500 Subject: [PATCH] Add PostgreSQL version restriction ManageIQ is only compatible with PostgreSQL 9.4 or 9.5, and many odd errors take a while to find when it's a simple version problem that could be found immediately. This adds a restriction to the AR adapter to maintain lazy-loading the connection as expected. --- config/initializers/postgres_required_versions.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 config/initializers/postgres_required_versions.rb diff --git a/config/initializers/postgres_required_versions.rb b/config/initializers/postgres_required_versions.rb new file mode 100644 index 00000000000..e98a1e3a4f6 --- /dev/null +++ b/config/initializers/postgres_required_versions.rb @@ -0,0 +1,8 @@ +ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend Module.new { + def initialize(*args) + super + if postgresql_version < 90400 || postgresql_version >= 90600 + raise "The version of PostgreSQL being connected to is incompatible with #{I18n.t("product.name")}" + end + end +}