MySQL · 721 bytes Raw Blame History
1 -- SPDX-License-Identifier: AGPL-3.0-or-later
2 --
3 -- S41g retention sweep support. The cleanup worker walks terminal
4 -- Actions rows by completion time, so give it narrow indexes that do
5 -- not bloat the hot queued/running paths.
6
7 -- +goose Up
8
9 CREATE INDEX workflow_steps_retention_idx
10 ON workflow_steps (completed_at)
11 WHERE completed_at IS NOT NULL
12 AND status IN ('completed', 'cancelled', 'skipped');
13
14 CREATE INDEX workflow_runs_retention_idx
15 ON workflow_runs (completed_at)
16 WHERE pinned = false
17 AND completed_at IS NOT NULL
18 AND status IN ('completed', 'cancelled');
19
20 -- +goose Down
21
22 DROP INDEX IF EXISTS workflow_runs_retention_idx;
23 DROP INDEX IF EXISTS workflow_steps_retention_idx;
24