mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Make reset-postgresql-sequences work on empty tables
This commit is contained in:
parent
c4d360e0ec
commit
787a7b864b
1 changed files with 3 additions and 2 deletions
|
@ -33,8 +33,9 @@ for table in sorted(mapped_classes):
|
||||||
for c in sequence_columns(table):
|
for c in sequence_columns(table):
|
||||||
max_value, = session.query(func.max(c)).one()
|
max_value, = session.query(func.max(c)).one()
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "%s.%s <- %s" % (table_name, c.name, max_value)
|
print "%s.%s <- %s" % (table_name, c.name, max_value or 0)
|
||||||
session.execute(func.setval(
|
session.execute(func.setval(
|
||||||
func.pg_get_serial_sequence(table_name, c.name),
|
func.pg_get_serial_sequence(table_name, c.name),
|
||||||
max_value,
|
max_value or 1,
|
||||||
|
max_value is not None,
|
||||||
))
|
))
|
||||||
|
|
Loading…
Add table
Reference in a new issue