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_projectsdata 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:
testTestTESTtest projectTest Applicationtesting 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=DELETEenvironment variable - Or use
REQUIRE_CONFIRMATION=falseto 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=truefor 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