lib/updateable_views_inheritance/postgresql_adapter.rb
# Resets sequence to the max value of the table's pk if present respecting inheritance (i.e. one sequence can be shared by many tables).
Resets sequence to the max value of the table's pk if present respecting inheritance .
Resets sequence to the max value of the table ' s pk if present respecting inheritance .
def reset_pk_sequence!(table, pk = nil, sequence = nil)
          parent = parent_table(table)
          if parent
            reset_pk_sequence!(parent, pk, sequence)
          else
            unless pk and sequence
              default_pk, default_sequence = pk_and_sequence_for(table)
              pk ||= default_pk
              sequence ||= default_sequence
            end
            if pk
              if sequence
                select_value <<-end_sql, 'Reset sequence'
                  SELECT setval('#{sequence}', (SELECT COALESCE(MAX(#{pk})+(SELECT increment_by FROM #{sequence}), (SELECT min_value FROM #{sequence})) FROM #{table}), false)
                end_sql
              else
                @logger.warn "#{table} has primary key #{pk} with no default sequence" if @logger
              end
            end
          end
        end
def reset_pk_sequence! ( table , pk = nil , sequence = nil ) parent = parent_table ( table ) if parent reset_pk_sequence! ( parent , pk , sequence ) else unless pk and sequence default_pk , default_sequence = pk_and_sequence_for ( table ) pk ||= default_pk sequence ||= default_sequence end if pk if sequence select_value <<-end_sql , 'Reset sequence' 
                  SELECT setval(' #{ sequence } ', (SELECT COALESCE(MAX( #{ pk } )+(SELECT increment_by FROM  #{ sequence } ), (SELECT min_value FROM  #{ sequence } )) FROM  #{ table } ), false)
                 end_sql else @logger . warn "#{table} has primary key #{pk} with no default sequence" if @logger end end end end
Resets sequence to the max value of the table's pk if present respecting inheritance (i.e.
Resets sequence to the max value of the table ' s pk if present respecting inheritance ( i . e .
table
<not_specific>
pk
<not_specific>
sequence
<not_specific>