mirror of
https://github.com/elmerfds/TrafegoDNS.git
synced 2026-01-13 22:59:39 -06:00
- Updated CLI usage documentation to reflect the unified CLI commands and removed references to JSON storage. - Added a new document detailing the SQLite storage architecture, benefits, migration process, and schema features. - Modified application startup to require SQLite initialization, removing fallback to JSON storage. - Enhanced database initialization logic to ensure successful migration from JSON to SQLite and log appropriate messages. - Updated database module to handle migration from JSON files and ensure application functionality relies solely on SQLite.
2.9 KiB
2.9 KiB
SQLite Storage in TrafegoDNS
TrafegoDNS has transitioned to using SQLite exclusively for data storage. This document explains the change, benefits, and migration process.
Storage Architecture
Previous Architecture (Legacy)
TrafegoDNS originally used a dual-storage approach:
- JSON files for record storage
- SQLite for database capabilities (with JSON as fallback)
This approach had benefits during the transition period but created consistency issues when records were modified in one storage system but not the other.
Current Architecture
TrafegoDNS now uses:
- SQLite as the exclusive storage solution
- One-time migration from JSON to SQLite if JSON files exist
- No fallbacks to JSON storage after migration
Benefits of SQLite-Only Storage
- Data Integrity: SQLite provides ACID transactions, ensuring database consistency
- Performance: Faster queries and data operations, especially with large datasets
- Reduced Complexity: Simplified codebase without dual-write logic
- Reliability: No risk of data inconsistency between multiple storage formats
- Better Querying: Full SQL capabilities for complex data operations
- Smaller Footprint: More efficient storage compared to JSON files
Migration Process
When TrafegoDNS starts:
- The application initializes the SQLite database
- If JSON files exist and haven't been migrated, it performs a one-time migration to SQLite
- Once migrated, the application only uses SQLite for all operations
- Original JSON files remain as backups but are not updated
CLI Commands
All TrafegoDNS CLI commands now work exclusively with SQLite:
# List records
trafegodns records
# Search for records
trafegodns search 'type=CNAME'
# Process DNS records
trafegodns process
# Show database status
trafegodns status
# Delete a record
trafegodns delete 123
# Update a record
trafegodns update 15 content=192.168.1.10
# Mark a record as managed
trafegodns update 8 managed=1
Schema Features
The SQLite database includes several important columns:
id: Primary key for database operationsrecord_id: External record identifierprovider: DNS provider nametype: DNS record type (A, CNAME, etc.)name: DNS record name/hostnamecontent: Record content/valuettl: Time to liveis_orphaned: Flag for orphaned recordstracked_at: When the record was updatedlast_processed: When the record was last processedmanaged: Flag indicating if the record is actively managed by TrafegoDNSorphaned_at: When the record became orphanedfingerprint: Hash to detect content changes
Requirements
SQLite is now a required dependency for TrafegoDNS. The application will:
- Check for SQLite during startup
- Exit with an error if SQLite is not available or cannot be initialized
- Provide clear error messages about required dependencies
The CLI tools also require the sqlite3 command-line utility to function properly.