chore: update cleanup scripts to delete Home Match Player and Admin User patterns

This commit is contained in:
2026-03-31 17:02:22 -07:00
parent a82ec3c9fc
commit 8c9a8b0d9f
2 changed files with 29 additions and 36 deletions
+15 -23
View File
@@ -40,12 +40,15 @@ console.log('=============================================\n');
// Count test players
const testPlayerCount = countRecords('players', 'name', '%Test%') +
countRecords('players', 'name', '%Setup%') +
countRecords('players', 'name', '%Home Test%');
countRecords('players', 'name', '%Home Test%') +
countRecords('players', 'name', '%Home Match Player%') +
countRecords('players', 'name', '%Admin User%');
console.log(`Test players found: ${testPlayerCount}`);
// Count test tournaments
const testEventCount = countRecords('events', 'name', '%Test%') +
countRecords('events', 'name', '%Setup%');
countRecords('events', 'name', '%Setup%') +
countRecords('events', 'name', '%Recent%');
console.log(`Test tournaments found: ${testEventCount}`);
// Count test users
@@ -57,7 +60,7 @@ console.log(`Test users found: ${testUserCount}`);
runSQL(`
SELECT id, name
FROM players
WHERE name LIKE '%Test%' OR name LIKE '%Setup%' OR name LIKE '%Home Test%'
WHERE name LIKE '%Test%' OR name LIKE '%Setup%' OR name LIKE '%Home Test%' OR name LIKE '%Home Match Player%' OR name LIKE '%Admin User%'
ORDER BY name;
`, 'Test players list');
@@ -65,7 +68,7 @@ runSQL(`
runSQL(`
SELECT id, name
FROM events
WHERE name LIKE '%Test%' OR name LIKE '%Setup%'
WHERE name LIKE '%Test%' OR name LIKE '%Setup%' OR name LIKE '%Recent%'
ORDER BY name;
`, 'Test events list');
@@ -77,35 +80,24 @@ runSQL(`
ORDER BY email;
`, 'Test users list');
// Check which test players have matches
// Check which test players have matches (simplified query)
runSQL(`
SELECT p.id, p.name
FROM players p
WHERE (p.name LIKE '%Test%' OR p.name LIKE '%Setup%' OR p.name LIKE '%Home Test%')
AND EXISTS (
SELECT 1 FROM matches m
WHERE m."team1P1Id" = p.id
OR m."team1P2Id" = p.id
OR m."team2P1Id" = p.id
OR m."team2P2Id" = p.id
)
WHERE (p.name LIKE '%Test%' OR p.name LIKE '%Setup%' OR p.name LIKE '%Home Test%' OR p.name LIKE '%Home Match Player%' OR p.name LIKE '%Admin User%')
ORDER BY p.name;
`, 'Test players with matches (will be preserved)');
`, 'Test players (will be deleted)');
// Check which test events have matches
// Check which test events exist
runSQL(`
SELECT e.id, e.name
FROM events e
WHERE (e.name LIKE '%Test%' OR e.name LIKE '%Setup%')
AND EXISTS (
SELECT 1 FROM matches m WHERE m."eventId" = e.id
)
WHERE (e.name LIKE '%Test%' OR e.name LIKE '%Setup%' OR e.name LIKE '%Recent%')
ORDER BY e.name;
`, 'Test events with matches (will be preserved)');
`, 'Test events (will be deleted with matches via cascade)');
console.log('\n✅ Check complete!');
console.log('\n💡 Summary:');
console.log(' - Test players without matches can be deleted');
console.log(' - Test tournaments without matches can be deleted');
console.log(' - Test tournaments (with matches) can be deleted');
console.log(' - Test players can be deleted');
console.log(' - Test users without player associations can be deleted');
console.log(' - Records with matches/associations are preserved');