

def sequence_reset_sql(self, style, model_list):
    from django.db import models
    output = []
    qn = self.quote_name
    for model in model_list:
        for f in model._meta.local_fields:
            if isinstance(f, models.AutoField):
                output.append(("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % (style.SQL_KEYWORD('SELECT'), style.SQL_FIELD(qn(('%s_%s_seq' % (model._meta.db_table, f.column)))), style.SQL_FIELD(qn(f.column)), style.SQL_FIELD(qn(f.column)), style.SQL_KEYWORD('IS NOT'), style.SQL_KEYWORD('FROM'), style.SQL_TABLE(qn(model._meta.db_table)))))
                break
        for f in model._meta.many_to_many:
            if (not f.rel.through):
                output.append(("%s setval('%s', coalesce(max(%s), 1), max(%s) %s null) %s %s;" % (style.SQL_KEYWORD('SELECT'), style.SQL_FIELD(qn(('%s_id_seq' % f.m2m_db_table()))), style.SQL_FIELD(qn('id')), style.SQL_FIELD(qn('id')), style.SQL_KEYWORD('IS NOT'), style.SQL_KEYWORD('FROM'), style.SQL_TABLE(qn(f.m2m_db_table())))))
    return output

dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/db/backends/postgresql/operations.py DatabaseOperations.sequence_reset_sql/original