migrateUsers.js: logic updated to resume if failed

This commit is contained in:
Vladimir D 2024-02-15 20:46:05 +04:00
parent a08af787d7
commit f8c84b6ef5

View file

@ -33,7 +33,7 @@ for (let line of ldapSearchOutput.split('\n')) {
console.log('Found usermapping:', users);
for (let id in users) {
let uid = execSync(`${postgresCmd} -AXqtc "SELECT u.id FROM users u JOIN accounts a ON a.id=u.account_id WHERE a.username='${users[id]}'"`).toString().trim();
let uid = execSync(`${postgresCmd} -AXqtc "SELECT u.id FROM users u JOIN accounts a ON a.id=u.account_id WHERE NOT EXISTS (SELECT 1 FROM identities WHERE provider='openid_connect' AND uid='${users[id]}') AND a.username='${users[id]}'"`).toString().trim();
if (!uid)
continue;