Skip to content

Refactor: move migrations over to new db package.#815

Merged
arabcoders merged 11 commits intomasterfrom
dev
May 2, 2026
Merged

Refactor: move migrations over to new db package.#815
arabcoders merged 11 commits intomasterfrom
dev

Conversation

@arabcoders
Copy link
Copy Markdown
Owner

@arabcoders arabcoders commented May 2, 2026

This pull request introduces a major update to WatchState, focusing on migrating to a new versioned database schema (v02), updating related configuration and documentation, and improving the system command API. The changes also enhance the pruning configuration, update task scheduling, and refactor database initialization and dependency injection for better maintainability and extensibility.

Database migration and configuration:

  • Migrated the database schema to the new versioned v02 format, updating the default database file location, migration logic, and related configuration. Old database files are preserved as .migrated backups after upgrade.
  • Refactored database connection setup to use a new PdoFactory, and updated dependency injection to improve modularity and future extensibility.
  • users i.e. sub users/profiles databases uses same naming as main db watchstate_v02.db.

System command API improvements:

  • Added a new GET /v1/api/system/command endpoint to list recent command sessions, and clarified session replay, expiry, and error handling in the API documentation.
  • Updated command names in documentation and examples from system:index to db:index to match the new schema and command structure.

Pruning and task scheduling:

  • Improved log pruning configuration by supporting flexible past-relative time expressions (e.g., -7 DAYS) and added validation to ensure only valid, past times are accepted.
  • Updated the scheduled prune task to run every 5 minutes, always enabled, and now runs all registered prune handlers. (config/config.php, config/config.phpL373-R386)

@arabcoders arabcoders merged commit 16c7925 into master May 2, 2026
12 checks passed
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.

1 participant