@@ -37,7 +37,7 @@ const SNAPSHOT_RETENTION_RECENT_COUNT: usize = 2;
3737const SQLITE_BUSY_TIMEOUT_MS : u64 = 5_000 ;
3838const STORAGE_RETRY_ATTEMPTS : usize = 4 ;
3939const STORAGE_RETRY_BASE_DELAY_MS : u64 = 120 ;
40- const STORAGE_SCHEMA_VERSION : i64 = 5 ;
40+ const STORAGE_SCHEMA_VERSION : i64 = 6 ;
4141const STORAGE_SCHEMA_STATE_TABLE : & str = "storage_schema_state" ;
4242// Version 4 adds assignedTo to the desktop-native FTS schema and forces one
4343// content rebuild after the corrected triggers are installed.
@@ -85,6 +85,7 @@ CREATE TABLE IF NOT EXISTS tasks (
8585 location TEXT,
8686 projectId TEXT REFERENCES projects(id) ON DELETE SET NULL,
8787 sectionId TEXT REFERENCES sections(id) ON DELETE SET NULL,
88+ viewSectionIds TEXT,
8889 areaId TEXT REFERENCES areas(id) ON DELETE SET NULL,
8990 orderNum INTEGER,
9091 boardOrder INTEGER,
@@ -518,6 +519,7 @@ fn initialize_sqlite_schema(conn: &mut Connection) -> Result<i64, String> {
518519 ensure_column ( & transaction, "tasks" , "focusOrder" , "INTEGER" ) ?;
519520 ensure_tasks_area_column ( & transaction) ?;
520521 ensure_tasks_section_column ( & transaction) ?;
522+ ensure_column ( & transaction, "tasks" , "viewSectionIds" , "TEXT" ) ?;
521523 ensure_tasks_organization_indexes ( & transaction) ?;
522524 ensure_projects_order_column ( & transaction) ?;
523525 ensure_column ( & transaction, "projects" , "sequentialScope" , "TEXT" ) ?;
@@ -1676,10 +1678,11 @@ fn replace_task_row(conn: &Connection, task: &Value) -> Result<(), String> {
16761678 let recurrence_json = json_str ( task. get ( "recurrence" ) ) ;
16771679 let checklist_json = json_str ( task. get ( "checklist" ) ) ;
16781680 let attachments_json = json_str ( task. get ( "attachments" ) ) ;
1681+ let view_section_ids_json = json_str ( task. get ( "viewSectionIds" ) ) ;
16791682 let normalized_rev = normalized_revision_for_storage ( task. get ( "rev" ) ) ;
16801683 let normalized_rev_by = normalized_rev_by ( task. get ( "revBy" ) ) ;
16811684 conn. execute (
1682- "INSERT OR REPLACE INTO tasks (id, title, status, priority, energyLevel, assignedTo, taskMode, startTime, relativeStartOffset, dueDate, recurrence, showFutureRecurrence, pushCount, tags, contexts, checklist, description, textDirection, attachments, location, projectId, sectionId, areaId, orderNum, boardOrder, focusOrder, isFocusedToday, timeEstimate, suppressMindwtrReminders, repeatReminderMinutes, reviewAt, completedAt, statusBeforeProjectArchive, completedAtBeforeProjectArchive, isFocusedTodayBeforeProjectArchive, projectArchivedAt, rev, revBy, createdAt, updatedAt, deletedAt, purgedAt, timeSpentMinutes) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32, ?33, ?34, ?35, ?36, ?37, ?38, ?39, ?40, ?41, ?42, ?43)" ,
1685+ "INSERT OR REPLACE INTO tasks (id, title, status, priority, energyLevel, assignedTo, taskMode, startTime, relativeStartOffset, dueDate, recurrence, showFutureRecurrence, pushCount, tags, contexts, checklist, description, textDirection, attachments, location, projectId, sectionId, viewSectionIds, areaId, orderNum, boardOrder, focusOrder, isFocusedToday, timeEstimate, suppressMindwtrReminders, repeatReminderMinutes, reviewAt, completedAt, statusBeforeProjectArchive, completedAtBeforeProjectArchive, isFocusedTodayBeforeProjectArchive, projectArchivedAt, rev, revBy, createdAt, updatedAt, deletedAt, purgedAt, timeSpentMinutes) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32, ?33, ?34, ?35, ?36, ?37, ?38, ?39, ?40, ?41, ?42, ?43, ?44 )" ,
16831686 params ! [
16841687 task. get( "id" ) . and_then( |v| v. as_str( ) ) . unwrap_or_default( ) ,
16851688 task. get( "title" ) . and_then( |v| v. as_str( ) ) . unwrap_or_default( ) ,
@@ -1703,6 +1706,7 @@ fn replace_task_row(conn: &Connection, task: &Value) -> Result<(), String> {
17031706 task. get( "location" ) . and_then( |v| v. as_str( ) ) ,
17041707 task. get( "projectId" ) . and_then( |v| v. as_str( ) ) ,
17051708 task. get( "sectionId" ) . and_then( |v| v. as_str( ) ) ,
1709+ view_section_ids_json,
17061710 task. get( "areaId" ) . and_then( |v| v. as_str( ) ) ,
17071711 task. get( "order" )
17081712 . and_then( |v| v. as_f64( ) )
@@ -1879,6 +1883,11 @@ fn row_to_task_value(row: &rusqlite::Row<'_>) -> Result<Value, rusqlite::Error>
18791883 map. insert ( "sectionId" . to_string ( ) , Value :: String ( v) ) ;
18801884 }
18811885 }
1886+ let view_section_ids_raw: Option < String > = row. get ( "viewSectionIds" ) ?;
1887+ let view_section_ids_val = parse_json_value ( view_section_ids_raw) ;
1888+ if !view_section_ids_val. is_null ( ) {
1889+ map. insert ( "viewSectionIds" . to_string ( ) , view_section_ids_val) ;
1890+ }
18821891 if let Ok ( val) = row. get :: < _ , Option < String > > ( "areaId" ) {
18831892 if let Some ( v) = val {
18841893 map. insert ( "areaId" . to_string ( ) , Value :: String ( v) ) ;
@@ -3171,8 +3180,9 @@ fn replace_data_in_transaction(conn: &Connection, mut data: Value) -> Result<Val
31713180 let recurrence_json = json_str ( task. get ( "recurrence" ) ) ;
31723181 let checklist_json = json_str ( task. get ( "checklist" ) ) ;
31733182 let attachments_json = json_str ( task. get ( "attachments" ) ) ;
3183+ let view_section_ids_json = json_str ( task. get ( "viewSectionIds" ) ) ;
31743184 conn. execute (
3175- "INSERT OR REPLACE INTO tasks (id, title, status, priority, energyLevel, assignedTo, taskMode, startTime, relativeStartOffset, dueDate, recurrence, showFutureRecurrence, pushCount, tags, contexts, checklist, description, textDirection, attachments, location, projectId, sectionId, areaId, orderNum, boardOrder, focusOrder, isFocusedToday, timeEstimate, suppressMindwtrReminders, repeatReminderMinutes, reviewAt, completedAt, statusBeforeProjectArchive, completedAtBeforeProjectArchive, isFocusedTodayBeforeProjectArchive, projectArchivedAt, rev, revBy, createdAt, updatedAt, deletedAt, purgedAt, timeSpentMinutes) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32, ?33, ?34, ?35, ?36, ?37, ?38, ?39, ?40, ?41, ?42, ?43)" ,
3185+ "INSERT OR REPLACE INTO tasks (id, title, status, priority, energyLevel, assignedTo, taskMode, startTime, relativeStartOffset, dueDate, recurrence, showFutureRecurrence, pushCount, tags, contexts, checklist, description, textDirection, attachments, location, projectId, sectionId, viewSectionIds, areaId, orderNum, boardOrder, focusOrder, isFocusedToday, timeEstimate, suppressMindwtrReminders, repeatReminderMinutes, reviewAt, completedAt, statusBeforeProjectArchive, completedAtBeforeProjectArchive, isFocusedTodayBeforeProjectArchive, projectArchivedAt, rev, revBy, createdAt, updatedAt, deletedAt, purgedAt, timeSpentMinutes) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20, ?21, ?22, ?23, ?24, ?25, ?26, ?27, ?28, ?29, ?30, ?31, ?32, ?33, ?34, ?35, ?36, ?37, ?38, ?39, ?40, ?41, ?42, ?43, ?44 )" ,
31763186 params ! [
31773187 task. get( "id" ) . and_then( |v| v. as_str( ) ) . unwrap_or_default( ) ,
31783188 task. get( "title" ) . and_then( |v| v. as_str( ) ) . unwrap_or_default( ) ,
@@ -3196,6 +3206,7 @@ fn replace_data_in_transaction(conn: &Connection, mut data: Value) -> Result<Val
31963206 task. get( "location" ) . and_then( |v| v. as_str( ) ) ,
31973207 task. get( "projectId" ) . and_then( |v| v. as_str( ) ) ,
31983208 task. get( "sectionId" ) . and_then( |v| v. as_str( ) ) ,
3209+ view_section_ids_json,
31993210 task. get( "areaId" ) . and_then( |v| v. as_str( ) ) ,
32003211 task. get( "order" )
32013212 . and_then( |v| v. as_f64( ) )
@@ -5693,6 +5704,10 @@ mod tests {
56935704 "location" : "Office" ,
56945705 "projectId" : "project-full" ,
56955706 "sectionId" : "section-1" ,
5707+ "viewSectionIds" : {
5708+ "someday" : "someday-books" ,
5709+ "future-scope" : "future-heading"
5710+ } ,
56965711 "areaId" : "area-1" ,
56975712 "order" : 17 ,
56985713 "boardOrder" : 4 ,
@@ -5809,6 +5824,7 @@ mod tests {
58095824 "location" ,
58105825 "projectId" ,
58115826 "sectionId" ,
5827+ "viewSectionIds" ,
58125828 "areaId" ,
58135829 "order" ,
58145830 "boardOrder" ,
0 commit comments