Permalink
Browse files

Merge pull request #125 from mnaberez/postgresql_version

Restore support for PostgreSQL with Rails versions before 5.0.0
  • Loading branch information...
aserafin committed Apr 7, 2018
2 parents 9a5913f + 0ad8e46 commit ba11d38b81cb86d6b86cc8e9cccee95b6dcc35dc
Showing with 9 additions and 1 deletion.
  1. +7 −0 CHANGELOG.md
  2. +2 −1 lib/seed-fu/seeder.rb
@@ -1,3 +1,10 @@
Version 2.3.8
-------------

Bug fixes:

* Restored support for PostgreSQL with Rails versions before 5.0.0 broken in Seed Fu 2.3.7.

Version 2.3.7
-------------

@@ -91,7 +91,8 @@ def update_id_sequence
quoted_id = @model_class.connection.quote_column_name(@model_class.primary_key)
sequence = @model_class.sequence_name

if @model_class.connection.postgresql_version >= 100000
# TODO postgresql_version was made public in Rails 5.0.0, remove #send when support for earlier versions are dropped
if @model_class.connection.send(:postgresql_version) >= 100000
sql =<<-EOS
SELECT setval('#{sequence}', (SELECT GREATEST(MAX(#{quoted_id})+(SELECT seqincrement FROM pg_sequence WHERE seqrelid = '#{sequence}'::regclass), (SELECT seqmin FROM pg_sequence WHERE seqrelid = '#{sequence}'::regclass)) FROM #{@model_class.quoted_table_name}), false)
EOS

0 comments on commit ba11d38

Please sign in to comment.