db_preferences_postgresql.rb 774 B

12345678910111213141516171819202122
  1. # postgresql
  2. if ActiveRecord::Base.connection_config[:adapter] == 'postgresql'
  3. Rails.application.config.db_case_sensitive = true
  4. Rails.application.config.db_like = 'ILIKE'
  5. # postgresql version check
  6. # example output: "9.5.0"
  7. server_version = ActiveRecord::Base.connection.select_rows('SHOW server_version;')[0][0]
  8. (major, minor) = server_version.split('.')
  9. if major.to_i < 9 || (major.to_i == 9 && minor.to_i < 1)
  10. # rubocop:disable Rails/Output
  11. # rubocop:disable Rails/Exit
  12. p '+++++++++++++++++++++++++++++++++++++++++++++++++++++'
  13. p '+ I\'m sorry, PostgreSQL 9.1+ is required +'
  14. p '+++++++++++++++++++++++++++++++++++++++++++++++++++++'
  15. exit 1
  16. # rubocop:enable Rails/Exit
  17. # rubocop:enable Rails/Output
  18. end
  19. end