This directory contains scripts to safely delete projects with titles that are "test" or start with "test" from Gigya DS.
A straightforward script that deletes test projects with minimal configuration.
Features:
- Identifies projects with titles matching "test" patterns
- Soft deletes projects (marks as deleted rather than permanent removal)
- Provides summary statistics and verification
A comprehensive script with extensive safety features and configuration options.
Features:
- Dry run mode to preview deletions
- Confirmation prompts for safety
- Flexible matching patterns (exact match, starts with, custom patterns)
- Case sensitivity options
- Batch processing with rate limiting
- Detailed analysis and reporting
- Comprehensive verification
IMPORTANT: These scripts perform soft deletes by marking projects as deleted: true
rather than permanently removing them from the database. This allows for potential recovery if needed.
-
Environment Variables:
export GIGYA_API_KEY="your_api_key" export GIGYA_APP_KEY="your_app_key" export GIGYA_APP_SECRET="your_app_secret" export GIGYA_DOMAIN="accounts.eu1.gigya.com" # Optional, defaults to EU1 -
Permissions:
- Ensure your Gigya credentials have write access to the
oss_projects
data store
- Ensure your Gigya credentials have write access to the
# Delete all test projects (basic version) npx tsx delete-test-projects.ts
# Preview what would be deleted without making changes DRY_RUN=true npx tsx delete-test-projects-advanced.ts
# Delete test projects with confirmation prompt CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts
# Delete test projects without confirmation (use with caution!) REQUIRE_CONFIRMATION=false npx tsx delete-test-projects-advanced.ts
# Only match "Test" with exact case CASE_SENSITIVE=true npx tsx delete-test-projects-advanced.ts
# Only delete projects with title exactly "test" EXACT_MATCH_ONLY=true npx tsx delete-test-projects-advanced.ts
# Delete projects matching custom patterns CUSTOM_PATTERNS="demo,sample,temp" npx tsx delete-test-projects-advanced.ts
Environment Variable | Default | Description |
---|---|---|
DRY_RUN | false | Preview deletions without executing them |
REQUIRE_CONFIRMATION | true | Require manual confirmation before deletion |
CASE_SENSITIVE | false | Use case-sensitive title matching |
EXACT_MATCH_ONLY | false | Only delete exact "test" matches, not "test*" |
CUSTOM_PATTERNS | "" | Comma-separated additional patterns to match |
CONFIRM_DELETE | "" | Set to "DELETE" to confirm deletion |
The scripts will delete projects with titles that:
- Are exactly "test" (case insensitive)
- Start with "test" (case insensitive)
Examples of matched titles:
test
Test
TEST
test project
Test Application
testing something
With EXACT_MATCH_ONLY=true
, only projects with title exactly "test" will be deleted.
You can specify additional patterns to match:
CUSTOM_PATTERNS="demo,sample,temp,prototype"
This will also delete projects containing these words in their titles.
🔍 Analyzing projects for test patterns...
📊 Project Analysis:
📁 Total active projects: 25
🧪 Test projects found: 3
🎯 Exact 'test' matches: 1
🔤 Starts with 'test': 2
🔧 Custom pattern matches: 0
📋 Projects that will be deleted:
1. "test" - Exact match: 'test'
👤 Author: User I123456
📅 Created: 12/3/2024
2. "test project" - Starts with 'test'
👤 Author: Developer
📅 Created: 12/2/2024
🗑️ Starting test project deletion...
📦 Processing batch 1/1
🔄 Deleting "test"
📝 Reason: Exact match: 'test'
✅ Successfully deleted
📊 Final Deletion Report:
✅ Successfully deleted: 3 projects
❌ Errors: 0 projects
📈 Success rate: 100.0%
- Preview all changes before execution
- See exactly which projects would be deleted
- No actual modifications made
- Manual confirmation required by default
- Must type "DELETE" exactly to proceed
- Can be disabled for automation
- Projects marked as
deleted: true
- Original data preserved
- Can potentially be recovered
- Processes projects in small batches
- Rate limiting to prevent API overload
- Graceful error handling
- Confirms deletions were successful
- Reports any remaining test projects
- Shows before/after statistics
If you need to recover deleted projects:
# Find deleted test projects # You would need to create a recovery script that: # 1. Searches for projects with deleted=true # 2. Filters for test projects # 3. Sets deleted=false to restore them
✅ No test projects found to delete.
- Verify projects exist with test-like titles
- Check case sensitivity settings
- Ensure projects aren't already deleted
❌ Failed to delete: Access denied
- Verify Gigya credentials have write permissions
- Check API key, app key, and secret are correct
- Ensure you have access to the oss_projects data store
❌ Deletion not confirmed. Exiting.
- Set
CONFIRM_DELETE=DELETE
environment variable - Or use
REQUIRE_CONFIRMATION=false
to skip confirmation
❌ Error: Too many requests
- The script includes built-in rate limiting
- If issues persist, increase delay between requests
- Process smaller batches
-
Always start with dry run:
DRY_RUN=true npx tsx delete-test-projects-advanced.ts -
Review the analysis carefully:
- Check the list of projects to be deleted
- Verify no legitimate projects are included
- Pay attention to author and creation date
-
Use confirmation for safety:
- Keep
REQUIRE_CONFIRMATION=true
for manual operations - Only disable for trusted automated processes
- Keep
-
Test with exact match first:
EXACT_MATCH_ONLY=true DRY_RUN=true npx tsx delete-test-projects-advanced.ts -
Backup considerations:
- Consider exporting project data before deletion
- Soft deletes allow recovery, but backup is safer
These deletion scripts work well with other project management scripts:
- After data imports: Clean up test projects created during development
- Before production: Remove test data before going live
- Regular maintenance: Periodic cleanup of test projects
# 1. Preview what would be deleted DRY_RUN=true npx tsx delete-test-projects-advanced.ts # 2. Delete exact "test" matches only EXACT_MATCH_ONLY=true CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts # 3. Delete all test projects CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts
# For CI/CD or automated environments REQUIRE_CONFIRMATION=false CUSTOM_PATTERNS="temp,demo" npx tsx delete-test-projects-advanced.ts
# Very careful deletion - exact matches only, case sensitive EXACT_MATCH_ONLY=true CASE_SENSITIVE=true CONFIRM_DELETE=DELETE npx tsx delete-test-projects-advanced.ts