-`user_auth_files` - User authentication file metadata
-`user_oauth2_credentials` - OAuth2 credentials per user/provider
**Billing & Subscriptions:**
-`account_tiers` - Subscription tier definitions
-`payment_methods` - User payment methods
-`user_subscriptions` - Active subscriptions
-`payment_transactions` - Payment history
**Analytics & Tracking:**
-`context_dimensions` - Context usage tracking
-`token_usage` - Token usage for rate limiting
-`user_token_usage` - User-specific token usage
-`model_embeddings` - Cached model embeddings
### cache.db (Cache Database)
This database contains ONLY temporary caching data:
-`cache` - General purpose cache
-`response_cache` - AI response caching
## Migration Issue
In some installations, configuration tables (especially `users`) were incorrectly created in `cache.db` instead of `aisbf.db`. This causes issues because:
1. Configuration data should persist across cache clears
2. The application expects configuration in `aisbf.db`
3. Cache database should be safe to delete without losing data
## Migration Process
### Step 1: Check Current State
First, verify which database contains your data:
```bash
# Check tables in cache.db
sqlite3 ~/.aisbf/cache.db ".tables"
# Check tables in aisbf.db
sqlite3 ~/.aisbf/aisbf.db ".tables"
```
If you see configuration tables (like `users`, `user_providers`, etc.) in `cache.db`, you need to migrate.
### Step 2: Dry Run
Test the migration without making changes:
```bash
python migrate_cache_to_aisbf.py --dry-run
```
This will show you:
- Which tables will be migrated
- How many rows will be copied
- Any potential issues
### Step 3: Perform Migration
Run the actual migration:
```bash
python migrate_cache_to_aisbf.py
```
The script will:
1. Create backups of both databases
2. Copy configuration tables from `cache.db` to `aisbf.db`
3. Preserve all existing data
4. Show a summary of migrated data
**Backup files are created automatically:**
-`~/.aisbf/cache_backup_YYYYMMDD_HHMMSS.db`
-`~/.aisbf/aisbf_backup_YYYYMMDD_HHMMSS.db`
### Step 4: Verify Migration
After migration, verify the data:
```bash
# Check users table in aisbf.db
sqlite3 ~/.aisbf/aisbf.db "SELECT COUNT(*) FROM users;"
# Check your user exists
sqlite3 ~/.aisbf/aisbf.db "SELECT username, role FROM users;"
```
### Step 5: Test Application
Start AISBF and verify:
1. You can log in with your existing credentials
2. All providers and rotations are available
3. User-specific configurations are preserved
```bash
# Start AISBF
aisbf
# Or if running from source
python main.py
```
### Step 6: Cleanup (Optional)
After confirming everything works, clean up `cache.db`:
```bash
python migrate_cache_to_aisbf.py --cleanup
```
This removes configuration tables from `cache.db`, leaving only cache tables.
## Advanced Options
### Force Overwrite
If destination tables already have data and you want to overwrite:
```bash
python migrate_cache_to_aisbf.py --force
```
### Custom Database Paths
If your databases are in non-standard locations:
```bash
python migrate_cache_to_aisbf.py \
--cache-db /path/to/cache.db \
--aisbf-db /path/to/aisbf.db
```
## Troubleshooting
### Issue: "Table already has rows in destination"
**Solution:** Use `--force` to overwrite, or manually inspect both databases to determine which has the correct data.
### Issue: Migration fails with "database is locked"
**Solution:** Stop AISBF before running migration:
Use DatabaseRegistry.get_config_database() instead for explicit type safety.
This method now returns ONLY the CONFIG database to preserve existing behaviour.
"""
logger.warning("⚠️ DEPRECATED: get_database() is deprecated. Use DatabaseRegistry.get_config_database() or DatabaseRegistry.get_cache_database() instead")
<pstyle="margin: 5px 0 0 0; color: #a0a0a0; font-size: 12px;">Use <codestyle="background: #0f3460; padding: 2px 4px; border-radius: 3px;">-1</code> for unlimited, <codestyle="background: #0f3460; padding: 2px 4px; border-radius: 3px;">0</code> to disable, or any positive number for the limit</p>
<pstyle="margin: 5px 0 0 0; color: #a0a0a0; font-size: 12px;">Use <codestyle="background: #0f3460; padding: 2px 4px; border-radius: 3px;">-1</code> for unlimited, <codestyle="background: #0f3460; padding: 2px 4px; border-radius: 3px;">0</code> to disable, or any positive number for the limit</p>
<h3style="margin-bottom: 15px; color: #e0e0e0;">Choose Your Plan</h3>
<pstyle="color: #a0a0a0; font-size: 16px; max-width: 600px; margin: 0 auto;">Select the perfect tier for your AI service needs. All plans include access to all providers, rotations, and autoselection features.</p>
<labelfor="batching_openai_max_batch_size">OpenAI Max Batch Size</label>
<inputtype="number"id="batching_openai_max_batch_size"name="batching_openai_max_batch_size"value="{{ config.batching.provider_settings.openai.max_batch_size if config.batching and config.batching.provider_settings and config.batching.provider_settings.openai else 10 }}"min="1">
<labelfor="batching_anthropic_max_batch_size">Anthropic Max Batch Size</label>
<inputtype="number"id="batching_anthropic_max_batch_size"name="batching_anthropic_max_batch_size"value="{{ config.batching.provider_settings.anthropic.max_batch_size if config.batching and config.batching.provider_settings and config.batching.provider_settings.anthropic else 5 }}"min="1">