Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PostgreSQL 10 #1

Merged
merged 3 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 2.3.7
-------------

Features:

* Postgresql >= 10.0 support

Version 2.3.6
-------------

Expand Down
14 changes: 11 additions & 3 deletions lib/seed-fu/seeder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,17 @@ def update_id_sequence
quoted_id = @model_class.connection.quote_column_name(@model_class.primary_key)
sequence = @model_class.sequence_name

@model_class.connection.execute <<-EOS
SELECT setval('#{sequence}', (SELECT GREATEST(MAX(#{quoted_id})+(SELECT increment_by FROM #{sequence}), (SELECT min_value FROM #{sequence})) FROM #{@model_class.quoted_table_name}), false)
EOS
if @model_class.connection.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
else
sql =<<-EOS
SELECT setval('#{sequence}', (SELECT GREATEST(MAX(#{quoted_id})+(SELECT increment_by FROM #{sequence}), (SELECT min_value FROM #{sequence})) FROM #{@model_class.quoted_table_name}), false)
EOS
end

@model_class.connection.execute sql
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/seed-fu/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module SeedFu
# The current version of Seed Fu
VERSION = '2.3.6'
VERSION = '2.3.7'
end