Version Numbers
Summary
Katalog uses THREE different version numbers for different purposes:
| Version | Scope | Purpose | Updated When |
|---|---|---|---|
| Application Version | Global | Running app version | Never (read-only) |
| DB Schema Version | Per database | Database structure | When schema changes |
| Catalog Data Version | Per catalog | Catalog data format | When catalog data migrated |
Key Rule: catalog_app_version should reflect the DATA FORMAT VERSION, not just which app created it.
A catalog is "v2.8" when its data includes all v2.8 fields, regardless of when it was created.
1. Application Version
What it is: The version of the Katalog application currently running
Where it's stored:
- CMake:
KATALOG_VERSION_STRINGfromsrc/version.h.in - Runtime:
collection->appVersionloaded at startup
Value: "2.8", "2.9", etc.
Purpose:
- Displayed in "About" dialog
- Used to check for updates
- Reference for feature compatibility
Updated: Never (it's the current running version)
2. Database Schema Version
What it is: The version of the database structure (tables, columns, indexes)
Where it's stored:
- Database:
parametertable,parameter_name = 'version' - Runtime:
collection->dbSchemaVersion
Value: "2.6", "2.8", etc.
Purpose:
- Triggers database migrations in
runDatabaseMigrations() - Ensures database structure matches application requirements
- ONE-TIME migration per database
Updated: When database structure changes requiring migration
Examples:
- v2.6 → v2.8: Add columns to
filetable (file_extension,file_type,mime_type, etc.) - Future: Add new tables, indexes, or columns
Migration Trigger:
if (currentSchemaVersion < "2.8") {
qDebug() << "Running database migration to 2.8...";
Database::runMigration_2_8(m_connectionName);
collection->dbSchemaVersion = "2.8";
collection->setDatabaseSchemaVersion();
}
3. Catalog Data Format Version
(catalog->appVersion / catalog_app_version)
What it is: The version of the data format WITHIN each catalog
Where it's stored:
- Database:
catalogtable,catalog_app_versioncolumn (one per catalog) - Memory:
.idxfile header - Runtime:
catalog->appVersion
Value: "2.6", "2.8", etc.
Purpose:
- Definition: Indicates to which database schema version the catalog is compliant and mandatory fields are populated in the catalog's files
- Triggers catalog-specific migrations when loading old
.idxfiles - Shows catalog compatibility in Devices/Catalog list (column 30, when "Display Full Table" is checked)
Updated:
- When a new Catalog is created (set to current app version)
- When old Catalog is loaded and migrated
Examples:
-
Catalog created in v2.6:
catalog_app_version = "2.6"- Files have:
file_name,file_size, etc. (6 columns) - Files DON'T have:
file_extension,file_type,mime_type, metadata fields
- Files have:
-
Catalog updated to v2.8:
catalog_app_version = "2.8"- Database hase: All v2.6 fields PLUS new fields (28 columns)
- Files have:
file_extension,file_type,mime_typepopulated - Files MAY have: metadata fields (if
includeMetadata != "None")
Migration Trigger:
// When loading .idx file
bool needsMigration = (appVersion < "2.8");
if (needsMigration) {
// Convert 6-column format to 28-column format
// Populate file_extension, file_type, mime_type from file names
appVersion = "2.8";
saveCatalogToFile(); // Save in new format
}
Relationship Between Versions
Application v2.8
├─ Database Schema v2.8 (ONE per database)
│ └─ Ensures: file table has 28 columns
│
└─ Catalog A: v2.6 (ONE per catalog)
│ └─ Files: 6 columns, needs migration
│
└─ Catalog B: v2.8 (ONE per catalog)
└─ Files: 28 columns, fully migrated
Key Insight: A database can have schema v2.8 but contain both:
- Old catalogs (v2.6 format) - need per-catalog migration
- New catalogs (v2.8 format) - already migrated
Use Cases
Use Case 1: User Upgrades from v2.6 to v2.8
Initial State:
- Application: v2.6
- Database Schema: v2.6
- Catalog A: v2.6 (in-memory
.idxfile, 6 columns) - Catalog B: v2.6 (in-memory
.idxfile, 6 columns)
User Actions:
- Install Katalog v2.8
- Open collection
What Happens:
Step 1: Database Migration (ONE TIME)
├─ Detect: dbSchemaVersion (2.6) < appVersion (2.8)
├─ Run: Database::runMigration_2_8()
│ └─ Add columns to file/filetemp tables
├─ Update: collection->dbSchemaVersion = "2.8"
└─ Save to parameter table
Step 2: First Catalog Load (PER CATALOG)
├─ User searches or opens Catalog A
├─ Detect: catalog->appVersion (2.6) < current (2.8)