Skip to content

Commit 2b3a3cd

Browse files
committed
update reverseMigration
1 parent fe4dab1 commit 2b3a3cd

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

packages/lib/auth0.cfc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ component {
443443
token = token
444444
);
445445
successCount++;
446+
sleep(500);
446447
} catch (any e) {
447448
application.fc.lib.error.logData(application.fc.lib.error.normalizeError(e));
448449
}
@@ -805,7 +806,6 @@ component {
805806
}
806807

807808
public query function getReverseMigratableUsers(string userIDs, numeric maxRows=-1) {
808-
maxRows = min(maxRows, 5000);
809809
var qAllUsers = queryNew("profileID, userID, email, given_name, family_name, name, user_id, password_hash, email_verified");
810810

811811
var userCondition;
@@ -964,6 +964,30 @@ component {
964964
}
965965

966966
public void function reverseMigration(required query qUsers) {
967+
var safeBatchSize = 5000;
968+
if (qUsers.recordCount <= 5000) {
969+
try {
970+
processReverseBatch(arguments.qUsers);
971+
} catch (any e) {
972+
application.fc.lib.error.logData(application.fc.lib.error.normalizeError(e));
973+
}
974+
} else {
975+
var totalRows = qUsers.recordCount;
976+
var currentIndex = 1;
977+
978+
while (currentIndex <= totalRows) {
979+
try {
980+
var endIndex = min(currentIndex + safeBatchSize - 1, totalRows);
981+
var batchQuery = createBatchQuery(qUsers, currentIndex, endIndex);
982+
processReverseBatch(arguments.qUsers);
983+
} catch (any e) {
984+
application.fc.lib.error.logData(application.fc.lib.error.normalizeError(e));
985+
}
986+
currentIndex += safeBatchSize;
987+
}
988+
}
989+
}
990+
public void function processReverseBatch(required query qUsers) {
967991
// remove new user records
968992
removeUserRecords(qUsers=arguments.qUsers);
969993

webskin/a0Login/webtopBodyStatus.cfm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
</table>
302302
</cfoutput>
303303
<ft:processForm action="Reverse migration" Exit="true">
304-
<cfset application.fc.lib.auth0.reverseMigration(qUsers=qReverseMigratableUsers) />
304+
<cfset application.fc.lib.auth0.reverseMigration(qUsers=application.fc.lib.auth0.getReverseMigratableUsers(userIDs = "", maxRows=-1)) />
305305
</ft:processForm>
306306
<ft:form>
307307
<ft:buttonPanel>

0 commit comments

Comments
 (0)