Data access layer for project test schedules (ENH-006).
One schedule row per project (enforced by UNIQUE constraint on projectId). The scheduler process reads this table on startup and after every mutation to hot-reload cron jobs without a process restart.
Exports
getByProjectId— Get schedule for a project (or undefined).getAllEnabled— Get all enabled schedules (used at startup).upsert— Create or fully replace a project's schedule.setEnabled— Toggle enabled/disabled without clearing config.updateRunTimes— Record lastRunAt and nextRunAt after a fire.deleteByProjectId— Hard-delete (called on project delete/purge).
Methods
(static) deleteByProjectId(projectId)
Hard-delete a schedule for a project. Called when a project is permanently purged from the recycle bin.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string |
(static) getAll() → {Array.<Schedule>}
Get all schedules (enabled and disabled). Used by admin views.
Returns:
- Type
- Array.<Schedule>
(static) getAllEnabled() → {Array.<Schedule>}
Get all enabled schedules. Called by the scheduler on startup to restore all active cron jobs.
Returns:
- Type
- Array.<Schedule>
(static) getByProjectId(projectId) → {Schedule|undefined}
Get the schedule for a project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string |
Returns:
- Type
- Schedule | undefined
(static) setEnabled(projectId, enabled) → {Schedule|undefined}
Toggle a schedule's enabled state without changing its cron expression.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string | |
enabled |
boolean |
Returns:
Updated schedule, or undefined if not found.
- Type
- Schedule | undefined
(static) updateRunTimes(projectId, lastRunAt, nextRunAt)
Record lastRunAt and nextRunAt after a scheduled run fires.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string | |
lastRunAt |
string | ISO 8601 |
nextRunAt |
string | null | ISO 8601 or null |
(static) upsert(schedule) → {Schedule}
Create or fully replace a project's schedule. Uses INSERT OR REPLACE so the caller does not need to know whether a schedule already exists — the projectId UNIQUE constraint handles dedup.
Parameters:
| Name | Type | Description |
|---|---|---|
schedule |
Schedule |
Returns:
- Type
- Schedule
(inner) rowToSchedule(row) → {Schedule|undefined}
Convert a SQLite row to a Schedule object.
Parameters:
| Name | Type | Description |
|---|---|---|
row |
Object | undefined |
Returns:
- Type
- Schedule | undefined
Type Definitions
Schedule
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
id |
string | e.g. "SCH-1" |
projectId |
string | |
cronExpr |
string | 5-field cron expression |
timezone |
string | IANA timezone name |
enabled |
boolean | |
lastRunAt |
string | null | ISO 8601 or null |
nextRunAt |
string | null | ISO 8601 or null |
createdAt |
string | ISO 8601 |
updatedAt |
string | ISO 8601 |