db_preferences_postgresql.rb 822 B

1234567891011121314151617181920212223
  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. Rails.application.config.db_null_byte = false
  6. # postgresql version check
  7. # example output: "9.5.0"
  8. server_version = ActiveRecord::Base.connection.select_rows('SHOW server_version;')[0][0]
  9. (major, minor) = server_version.split('.')
  10. if major.to_i < 9 || (major.to_i == 9 && minor.to_i < 1)
  11. # rubocop:disable Rails/Output
  12. # rubocop:disable Rails/Exit
  13. p '+++++++++++++++++++++++++++++++++++++++++++++++++++++'
  14. p '+ I\'m sorry, PostgreSQL 9.1+ is required +'
  15. p '+++++++++++++++++++++++++++++++++++++++++++++++++++++'
  16. exit 1
  17. # rubocop:enable Rails/Exit
  18. # rubocop:enable Rails/Output
  19. end
  20. end