-- Framework session hooks belong only in the boot schema.
2
CREATE TRIGGER equipo_native_session_delete AFTER DELETE ON sessions BEGIN
3
UPDATE person_devices SET revoked_at=CURRENT_TIMESTAMP, revision=revision+1, result_cipher='', begin_cipher='' WHERE native_session_hash=OLD.token_hash AND revoked_at IS NULL;
4
DELETE FROM push_registrations WHERE credential IN (SELECT id FROM person_devices WHERE native_session_hash=OLD.token_hash);
5
DELETE FROM push_activities WHERE credential IN (SELECT id FROM person_devices WHERE native_session_hash=OLD.token_hash);
6
UPDATE push_outbox SET state='dropped',reason='forgotten',lease_until=NULL WHERE state='pending' AND credential IN (SELECT id FROM person_devices WHERE native_session_hash=OLD.token_hash);
7
END;
8
CREATE TRIGGER equipo_native_link_delete BEFORE DELETE ON home_identity_links BEGIN
9
DELETE FROM sessions WHERE method='home-assertion-native' AND subject=OLD.subject;