You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Patch to get seed-fu version 2.3.5 working with postgres10
For those with a legacy Rails 3.2 app needing to upgrade to Postgres 10 (e.g. running on heroku). This patch will enable you to use the 2.3.5 version of seed-fu (that works with Rails 3.2) against your postgres 10 database.
Add the patch file here ..
Add the following file at config/initializers/seed_fu_patch_for_v2_3_5_to_work_with_postgres_10.rb
SeedFu::Seeder.class_eval do
def update_id_sequence
if @model_class.connection.adapter_name == "PostgreSQL" or @model_class.connection.adapter_name == "PostGIS"
return if @model_class.primary_key.nil? || @model_class.sequence_name.nil?
quoted_id = @model_class.connection.quote_column_name(@model_class.primary_key)
sequence = @model_class.sequence_name
if ActiveRecord::Base.connection.select_value('SELECT version()').include?('PostgreSQL 10')
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
The text was updated successfully, but these errors were encountered:
Patch to get seed-fu version 2.3.5 working with postgres10
For those with a legacy Rails 3.2 app needing to upgrade to Postgres 10 (e.g. running on heroku). This patch will enable you to use the 2.3.5 version of seed-fu (that works with Rails 3.2) against your postgres 10 database.
Add the patch file here ..
Add the following file at config/initializers/seed_fu_patch_for_v2_3_5_to_work_with_postgres_10.rb
The text was updated successfully, but these errors were encountered: