33 lines
1.8 KiB
SQL
33 lines
1.8 KiB
SQL
-- +goose Up
|
|
-- A held chat action's approval is bound to the whole record of the action, not
|
|
-- only its name and arguments. Actions held before the binding existed carry
|
|
-- the narrow digest alone, so they are discarded rather than bound afterwards:
|
|
-- the person asks again. An approval already given is discarded, a pending
|
|
-- one expires, and the action stops.
|
|
UPDATE approvals.requests SET state = 'discarded',
|
|
discarded_because = 'it was approved before approvals were bound to the whole action'
|
|
WHERE state = 'approved' AND NOT counted
|
|
AND id IN (SELECT request_id FROM chat.actions WHERE state = 'approved');
|
|
UPDATE approvals.requests SET state = 'expired'
|
|
WHERE state = 'pending' AND id IN (SELECT request_id FROM chat.actions WHERE state = 'waiting');
|
|
UPDATE chat.actions SET state = 'expired',
|
|
result = 'It was held before approvals were bound to the whole action, so it didn''t run. Ask again.'
|
|
WHERE state = 'waiting';
|
|
UPDATE chat.actions SET state = 'failed',
|
|
result = 'It was held before approvals were bound to the whole action, so it didn''t run. Ask again.'
|
|
WHERE state = 'approved';
|
|
|
|
ALTER TABLE chat.actions ADD COLUMN binding jsonb, ADD COLUMN binding_digest text NOT NULL DEFAULT '';
|
|
|
|
-- Approving an action that can't be undone needs a fresh passkey assertion.
|
|
ALTER TABLE approvals.requests ADD COLUMN irreversible boolean NOT NULL DEFAULT false;
|
|
|
|
-- A confirmation ceremony is for one subject, such as an approval request. A
|
|
-- sign-in or registration ceremony has none.
|
|
ALTER TABLE governance.passkey_ceremonies ADD COLUMN subject text NOT NULL DEFAULT '';
|
|
|
|
-- +goose Down
|
|
ALTER TABLE governance.passkey_ceremonies DROP COLUMN subject;
|
|
ALTER TABLE approvals.requests DROP COLUMN irreversible;
|
|
ALTER TABLE chat.actions DROP COLUMN binding_digest, DROP COLUMN binding;
|