Created
January 25, 2024 07:55
-
-
Save tarkhil/9d1d13e64aeb5e0ebacf4c709c2e6cb3 to your computer and use it in GitHub Desktop.
Fix all sequences in postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Accidently, I've got and restored a dump without proper sequence values | |
SELECT concat('SELECT set', left(substr(column_default, 5),-1),', (select max(', column_name,') from ', table_schema, '.', table_name, ')+1);') FROM information_schema.columns where column_default like 'nextval%'; | |
-- just save it into SQL and run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment