-- For each table with an id sequence
SELECT setval(
        pg_get_serial_sequence('users', 'id'),
        COALESCE(MAX(id), 1)
    )
FROM users;
SELECT setval(
        pg_get_serial_sequence('wallets', 'id'),
        COALESCE(MAX(id), 1)
    )
FROM wallets;
SELECT setval(
        pg_get_serial_sequence('customer_wallets', 'id'),
        COALESCE(MAX(id), 1)
    )
FROM customer_wallets;
SELECT setval(
        pg_get_serial_sequence('companies', 'id'),
        COALESCE(MAX(id), 1)
    )
FROM companies;
SELECT setval(
        pg_get_serial_sequence('branches', 'id'),
        COALESCE(MAX(id), 1)
    )
FROM branches;
SELECT setval(
        pg_get_serial_sequence('supported_operations', 'id'),
        COALESCE(MAX(id), 1)
    )
FROM supported_operations;