I am trying to alter sequence of id field in my table using psycopg. This is works fine on my local server, but not working on production. I am not getting exceptions, the sequence is just not restarting.
def alter_sequence(last_id):
try:
dbname = settings.DATABASES['default']['NAME']
user = settings.DATABASES['default']['USER']
host = settings.DATABASES['default']['HOST']
password = settings.DATABASES['default']['PASSWORD']
port = settings.DATABASES['default']['PORT']
connection = psycopg2.connect(
dbname=dbname,
user=user,
password=password,
host=host,
port=port,
)
cursor = connection.cursor()
cursor.execute('ALTER SEQUENCE "gs_requests_id_seq" RESTART WITH {}'.format(last_id))
connection.close()
except Exception as e:
print(e)
pass
I double-checked the database settings - its correct. Other database operations, performed by django ORM with this settings is works fine.
I think, this is not enough information about my project settings but dont know what information I need to specify. I have postgres 9.6 on my local computer and 10.1 on production.