From 66ad1f8de7838a4b9733159ba0815826626a0951 Mon Sep 17 00:00:00 2001 From: ppworks Date: Wed, 25 Oct 2017 20:56:51 +0900 Subject: [PATCH 1/2] Support PostgreSQL 10 --- lib/seed-fu/seeder.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/seed-fu/seeder.rb b/lib/seed-fu/seeder.rb index 37a3ea8..def2a43 100644 --- a/lib/seed-fu/seeder.rb +++ b/lib/seed-fu/seeder.rb @@ -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 From 9a5913f01163ce9722791f492137df13ae8d7bdc Mon Sep 17 00:00:00 2001 From: aserafin Date: Fri, 24 Nov 2017 10:28:07 +0100 Subject: [PATCH 2/2] bump version to 2.3.7 --- CHANGELOG.md | 7 +++++++ lib/seed-fu/version.rb | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81dc396..baf714c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Version 2.3.7 +------------- + +Features: + +* Postgresql >= 10.0 support + Version 2.3.6 ------------- diff --git a/lib/seed-fu/version.rb b/lib/seed-fu/version.rb index 77116fd..65f7c65 100644 --- a/lib/seed-fu/version.rb +++ b/lib/seed-fu/version.rb @@ -1,4 +1,4 @@ module SeedFu # The current version of Seed Fu - VERSION = '2.3.6' + VERSION = '2.3.7' end