Skip to content

feat(web): make migrations storage agnostic - #1463

Merged
tyler-dane merged 13 commits into
mainfrom
feat/1461-migrations
Feb 19, 2026
Merged

feat(web): make migrations storage agnostic#1463
tyler-dane merged 13 commits into
mainfrom
feat/1461-migrations

Conversation

@tyler-dane

@tyler-dane tyler-dane commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

Closes #1461

…tories

- Refactored LocalTaskRepository and LocalEventRepository to utilize a new StorageAdapter, enhancing abstraction and flexibility in storage operations.
- Updated methods to delegate storage actions to the adapter, allowing for easier integration with different storage technologies (e.g., IndexedDB).
- Introduced a new storage adapter implementation using Dexie for managing tasks and events, including schema migrations and data handling.
- Added migration utilities to facilitate the transition from localStorage to the new storage system, ensuring data integrity and improved performance.
- Updated tests to reflect changes in storage handling and ensure compatibility with the new adapter structure.
…ions

- Introduced new test files for the storage adapter, including tests for IndexedDB operations and migration functionalities.
- Implemented tests for the LocalEventRepository to ensure proper integration with the new storage adapter.
- Added tests for migration processes, verifying the correct handling of tasks and events during transitions from localStorage to IndexedDB.
- Enhanced existing tests for task management to reflect changes in storage handling and ensure data integrity.
- Updated utility functions for creating mock tasks and events to streamline test setup and improve maintainability.
- Refactored imports for the storage adapter to point to the new adapter structure.
- Updated LocalEventRepository and LocalTaskRepository to utilize the new import paths.
- Introduced comprehensive tests for the new storage adapter, covering initialization, migration processes, and ensuring proper functionality with both tasks and events.
- Enhanced existing utility functions and tests to align with the updated storage architecture, improving maintainability and clarity.
…ests

- Deleted the db-init utility functions and their corresponding test file as they are now deprecated and delegate to the StorageAdapter.
- This cleanup aligns with the recent refactor to utilize the new storage architecture, enhancing maintainability and clarity in the codebase.
Copilot AI review requested due to automatic review settings February 19, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the storage layer to use an abstract StorageAdapter pattern, making the codebase storage-technology agnostic. The changes enable easier swapping of storage implementations (e.g., IndexedDB → SQLite) without modifying application code. The migration system is also redesigned to separate data migrations (storage-agnostic transformations) from external migrations (imports from localStorage).

Changes:

  • Introduced StorageAdapter interface and IndexedDBAdapter implementation to abstract storage operations
  • Replaced direct IndexedDB access with adapter pattern in repositories and utilities
  • Redesigned migration system with separate DataMigration and ExternalMigration types
  • Deprecated old storage utilities (task.storage.util, event.storage.util, compass-local.db, db-init.util, task-migration.util) while maintaining backward compatibility

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
packages/web/src/common/storage/adapter/storage.adapter.ts Defines abstract StorageAdapter interface for storage-agnostic operations
packages/web/src/common/storage/adapter/indexeddb.adapter.ts IndexedDB implementation of StorageAdapter using Dexie
packages/web/src/common/storage/adapter/adapter.ts Singleton factory for storage adapter with initialization logic
packages/web/src/common/storage/migrations/migrations.ts New migration system with runners for data and external migrations
packages/web/src/common/storage/migrations/migration.types.ts Type definitions for DataMigration and ExternalMigration
packages/web/src/common/storage/migrations/external/localstorage-tasks.ts Migrates tasks from localStorage to storage adapter
packages/web/src/common/utils/storage/task.storage.util.ts Deprecated compatibility layer delegating to StorageAdapter
packages/web/src/common/utils/storage/event.storage.util.ts Deprecated compatibility layer delegating to StorageAdapter
packages/web/src/common/utils/storage/compass-local.db.ts Deprecated database instance kept for test compatibility
packages/web/src/common/utils/storage/task-migration.util.ts Removed - migration logic moved to new system
packages/web/src/common/utils/storage/db-init.util.ts Removed - initialization moved to adapter
packages/web/src/common/repositories/task/local.task.repository.ts Updated to use StorageAdapter; added defensive validation in reorder
packages/web/src/common/repositories/event/local.event.repository.ts Updated to use StorageAdapter
packages/web/src/common/utils/app-init.util.ts Updated to use new initializeStorage function
packages/web/src/views/Now/hooks/useAvailableTasks.test.ts Updated to dispatch COMPASS_TASKS_SAVED_EVENT_NAME instead of storage events
Test files Added comprehensive tests for adapters, migrations, and updated existing tests

Comment thread packages/web/src/common/utils/storage/task.storage.util.ts Outdated
Comment thread packages/web/src/common/utils/storage/event.storage.util.ts Outdated
Comment thread packages/web/src/common/utils/storage/event.storage.util.ts Outdated
Comment thread packages/web/src/common/utils/storage/task.storage.util.ts Outdated
Comment thread packages/web/src/common/storage/adapter/storage.adapter.ts
Comment thread packages/web/src/common/storage/adapter/indexeddb.adapter.ts
Comment thread packages/web/src/common/utils/storage/task.storage.util.ts Outdated
…to use StorageAdapter

- Deleted the deprecated CompassLocalDB utility, which was previously used for direct database access.
- Updated tests to utilize the new StorageAdapter for event and task management, ensuring compatibility with the latest storage architecture.
- Introduced a new method for testing raw stored tasks, enhancing the testing framework for migration and normalization processes.
…te tests

- Deleted deprecated event storage utility functions that delegated to the StorageAdapter.
- Updated tests to utilize the StorageAdapter directly for event management, ensuring compatibility with the latest storage architecture.
- This cleanup enhances maintainability and aligns with the recent refactor to streamline storage operations.
- Removed deprecated task storage utility functions and their associated tests, transitioning to the new StorageAdapter for all task-related operations.
- Updated all relevant code and tests to utilize the StorageAdapter directly, ensuring compatibility with the latest storage architecture.
- This refactor enhances maintainability and aligns with the ongoing improvements in the storage system.
- Introduced a new `putTask` method in the `StorageAdapter` to handle saving or updating individual tasks based on their `_id`.
- Updated the `IndexedDBAdapter` to implement the `putTask` functionality, ensuring tasks can be inserted or updated efficiently.
- Enhanced tests across various components to validate the new `putTask` method, ensuring it integrates seamlessly with existing task management workflows.
- Refactored related utility functions to utilize the new `putTask` method, improving code maintainability and clarity.
- Introduced a new test suite for verifying the delete and restore functionality of tasks using Playwright.
- Implemented tests to ensure tasks can be deleted and subsequently restored from the undo toast.
- Enhanced utility functions for task visibility and deletion, improving test reliability and maintainability.
- Updated existing task utility functions to support new test scenarios, ensuring comprehensive coverage of task management features.
Copilot AI review requested due to automatic review settings February 19, 2026 18:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 44 out of 44 changed files in this pull request and generated 3 comments.

Comment thread e2e/utils/task-test-utils.ts
Comment thread packages/web/src/common/repositories/task/local.task.repository.ts
Comment thread packages/web/src/views/Day/hooks/tasks/useTaskActions.ts
…gement

- Added `saveTask` method to `LocalTaskRepository` for saving individual tasks, enhancing task management capabilities.
- Introduced `saveTask` method in `TaskRepository` interface to standardize task saving operations.
- Updated `CloudTaskRepository` to throw a not implemented error for `saveTask`, maintaining interface consistency.
- Refactored task loading and saving hooks to utilize the new `taskRepository` structure, improving code clarity and maintainability.
- Enhanced tests to cover the new `saveTask` functionality, ensuring robust task management workflows.
… tests

- Refactored `save` method in `LocalTaskRepository` to handle both single and multiple tasks, replacing the deprecated `saveTask` method.
- Updated the `TaskRepository` interface to reflect the new `save` method signature.
- Modified tests across various components to remove references to `saveTask` and ensure compatibility with the updated `save` method.
- Enhanced test coverage for the new saving logic, ensuring robust task management functionality.
@tyler-dane
tyler-dane merged commit e321ba6 into main Feb 19, 2026
5 checks passed
@tyler-dane
tyler-dane deleted the feat/1461-migrations branch February 19, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make migrations storage-agnostic

2 participants