OXYGENHUB
# fb8f35d025ab oxygenhub / crates / hub / migrations / 0105_board_views.sql
1.5 KiB · SQL · last changed Board views: saved views, filter bar, lanes, WIP limits, table, keys, card history (refs #361) 2 days ago source blame history raw
1
-- Board views and history (oxygenhub#361, #357): a column's work-in-progress
2
-- limit; a board's saved views, each a layout with its filter, lanes and
3
-- sort; and every card's moves (added, moved, archived, restored, removed),
4
-- from which cumulative flow, cycle time and forecasts are drawn. A move to
5
-- no column (NULL) takes the card off the board. Cards already on boards
6
-- start their history where they are now.
7
ALTER TABLE project_columns ADD COLUMN wip_limit INTEGER;
8
9
CREATE TABLE project_views (
10
    id         INTEGER PRIMARY KEY,
11
    project_id INTEGER NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
12
    name       TEXT NOT NULL,
13
    layout     TEXT NOT NULL DEFAULT 'board',
14
    q          TEXT NOT NULL DEFAULT '',
15
    lane       TEXT NOT NULL DEFAULT '',
16
    sort       TEXT NOT NULL DEFAULT '',
17
    position   INTEGER NOT NULL,
18
    created_ms INTEGER NOT NULL,
19
    UNIQUE (project_id, name)
20
);
21
22
CREATE TABLE project_card_moves (
23
    id         INTEGER PRIMARY KEY,
24
    project_id INTEGER NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
25
    card_id    INTEGER NOT NULL,
26
    column_id  INTEGER,
27
    at_ms      INTEGER NOT NULL
28
);
29
CREATE INDEX project_card_moves_by_project ON project_card_moves (project_id, at_ms);
30
31
INSERT INTO project_card_moves (project_id, card_id, column_id, at_ms)
32
    SELECT project_id, id, column_id, moved_ms FROM project_cards;
33
INSERT INTO project_card_moves (project_id, card_id, column_id, at_ms)
34
    SELECT project_id, id, NULL, archived_ms FROM project_cards WHERE archived_ms IS NOT NULL;