BEGIN; ALTER TABLE device ADD COLUMN factory_reset_counter bigint NOT NULL DEFAULT 0 CHECK (factory_reset_counter >= 0); COMMENT ON COLUMN device.factory_reset_counter IS 'Monotonic counter supplied by the physical device for authenticated factory-reset replay protection.'; ALTER TABLE web_event DROP CONSTRAINT web_event_event_type_check; ALTER TABLE web_event ADD CONSTRAINT web_event_event_type_check CHECK (event_type IN ( 'device.presence.changed','device.binding.reset', 'conversation.started','conversation.completed','conversation.failed', 'story.created','story.revised','media.upload.completed','export.ready', 'privacy_request.updated','device.command.updated')); COMMIT;