Files
cc-switch/src-tauri
Jason f93b21c97e fix: improve database migration robustness and schema consistency
This commit addresses several critical issues in the database migration system:

**Schema Consistency**
- Unified DEFAULT and NOT NULL constraints between CREATE TABLE and ALTER TABLE
- Fixed inconsistencies in: providers.meta, mcp_servers.tags, skills.installed_at, skill_repos.branch
- Ensures new installations and migrations produce identical schemas

**Security & Validation**
- Added SQL identifier validation to prevent potential injection risks
- Validates table and column names contain only alphanumeric characters and underscores

**Error Handling**
- Fixed table_exists() to distinguish "table not found" from "query failed"
- Properly propagates database errors instead of silently ignoring them
- Uses pattern matching on rusqlite::Error::QueryReturnedNoRows

**Transaction Safety**
- Implemented SAVEPOINT-based transaction protection for migrations
- Ensures user_version stays consistent with actual schema on failures
- Graceful rollback on migration errors (within SQLite's ALTER TABLE limitations)

**Testing**
- Enhanced test coverage to verify NOT NULL constraints and DEFAULT values
- Validates that migration produces the expected schema structure

These improvements ensure database migrations are more reliable, secure, and maintainable.
2025-11-24 22:34:33 +08:00
..
2025-11-22 19:18:35 +08:00
2025-11-24 11:00:45 +08:00
2025-11-24 11:00:45 +08:00
2025-11-22 19:18:35 +08:00