openvibers/openvibe.finance migrations0002_rules.sql
0002_rules.sql
| 1 | -- phase: expand |
| 2 | -- Category rules (plan §L.2: "normalising, categories, rules"): "a payee containing these words is this category", |
| 3 | -- applied to transactions nobody has categorised (on import, and to the past when the rule is made); a category the |
| 4 | -- person set stays theirs. The words are sealed with the person's key like a payee (they are one); match_mark is the |
| 5 | -- person's HMAC of the normalised words, so the same rule is one row. |
| 6 | CREATE TABLE finance_rules ( |
| 7 | id text COLLATE "C" PRIMARY KEY, |
| 8 | owner text COLLATE "C" NOT NULL, |
| 9 | match_enc text NOT NULL, |
| 10 | match_mark text COLLATE "C" NOT NULL, |
| 11 | category text NOT NULL, |
| 12 | created_at timestamptz NOT NULL DEFAULT now() |
| 13 | ); |
| 14 | CREATE UNIQUE INDEX finance_rules_one ON finance_rules (owner, match_mark); |
| 15 |