-- ======================================================
-- Reset sequences for LMS tables
-- ======================================================

SELECT setval(
    pg_get_serial_sequence('users', 'id'),
    COALESCE(MAX(id), 1)
)
FROM users;

SELECT setval(
    pg_get_serial_sequence('refresh_tokens', 'id'),
    COALESCE(MAX(id), 1)
)
FROM refresh_tokens;

SELECT setval(
    pg_get_serial_sequence('otps', 'id'),
    COALESCE(MAX(id), 1)
)
FROM otps;

SELECT setval(
    pg_get_serial_sequence('notifications', 'id'),
    COALESCE(MAX(id), 1)
)
FROM notifications;

SELECT setval(
    pg_get_serial_sequence('referral_codes', 'id'),
    COALESCE(MAX(id), 1)
)
FROM referral_codes;

SELECT setval(
    pg_get_serial_sequence('user_referrals', 'id'),
    COALESCE(MAX(id), 1)
)
FROM user_referrals;

SELECT setval(
    pg_get_serial_sequence('report_requests', 'id'),
    COALESCE(MAX(id), 1)
)
FROM report_requests;
