Fix a PostgreSQL sequence after restoring from backup
When you restore a database from a dump, it doesn't update the PostgreSQL SEQUENCE.
```sql
SELECT setval('mytable_id_seq', (SELECT MAX(id)+1 FROM mytable));
```
Test it with:
```sql
SELECT nextval('mytable_id_seq')
```
[source](https://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync)