Nuxt Crouton includes a comprehensive rollback system to safely remove generated collections. This is useful when you need to:
Remove a specific collection and all its generated files:
npx crouton rollback shop products
This removes:
Use --dry-run to see what would be removed:
npx crouton rollback shop products --dry-run
# Output:
📋 Preview: Would remove the following:
layers/shop/collections/products/app/components/
├── _Form.vue
└── List.vue
layers/shop/collections/products/app/composables/
└── useShopProducts.ts
layers/shop/collections/products/
└── types.ts
Total: 4 files
Proceed? (y/n)
Remove config entries but keep generated files:
npx crouton rollback shop products --keep-files
Useful when you want to keep customized components but remove them from the collection registry.
For scripts or automation:
npx crouton rollback shop products --force
Remove multiple collections at once.
npx crouton rollback-bulk --layer=shop
# Output:
⚠️ This will remove ALL collections in the 'shop' layer:
- products (5 files)
- categories (5 files)
- orders (5 files)
Total: 15 files
Continue? (y/n)
npx crouton rollback-bulk --config=./crouton.config.js
# Reads the config file and removes all collections defined in it
Same options as single rollback:
# Preview bulk changes
npx crouton rollback-bulk --layer=shop --dry-run
# Keep files, clean config
npx crouton rollback-bulk --layer=shop --keep-files
# Skip confirmation
npx crouton rollback-bulk --layer=shop --force
Launch an interactive UI to select collections:
npx crouton rollback-interactive
Interactive UI:
? Select collections to remove:
◯ shop/products (5 files)
◯ shop/categories (5 files)
◉ shop/orders (5 files)
◯ blog/posts (5 files)
Use arrow keys to navigate, space to select, enter to confirm
Options:
# Preview mode
npx crouton rollback-interactive --dry-run
# Keep files
npx crouton rollback-interactive --keep-files
The rollback system removes:
--keep-files)--keep-files)Best practices for safe rollbacks:
1. Always Preview First
npx crouton rollback shop products --dry-run
2. Check Git Status
git status
# Verify you have no uncommitted changes
3. Run Rollback
npx crouton rollback shop products
4. Verify Changes
git status
git diff
# Review what was removed
5. Commit or Revert
# If correct:
git add .
git commit -m "Remove products collection"
# If wrong:
git restore .
# 1. Remove the old collection
npx crouton rollback shop products --force
# 2. Regenerate with updated schema
npx crouton generate shop products --fields-file=product-schema.json
# Remove all test collections at once
npx crouton rollback-interactive
# Select all test collections in the UI
# Remove unused layer
npx crouton rollback-bulk --layer=experiments --force
# Keep customized files, just remove from registry
npx crouton rollback shop products --keep-files
The collection may already be removed or was never generated:
# Check what collections exist
ls layers/*/collections/
Files may be in use:
# Stop your dev server first
# Then try rollback again
The collection isn't registered in app.config.ts. This is safe to ignore, or you can manually verify:
// app.config.ts
export default defineAppConfig({
croutonCollections: {
// Check if collection exists here
}
})
Restore from Git:
git restore layers/shop/collections/products/
✅ DO:
--dry-run for preview before every rollbackgit status after rollback❌ DON'T:
--force without reviewing what will be removed