-- Add personal privacy switch for requiring approval when others add the user as a friend. -- Default is on to preserve the current "friend request needs approval" behavior. -- Run this for every tenant business database. The current test environment uses: -- default -> tinode -- system -> meeting_im SET @im_schema = 'tinode'; SET @im_sql = ( SELECT IF( COUNT(*) = 0, CONCAT('ALTER TABLE ', @im_schema, '.im_user_privacy_settings ADD COLUMN friend_request_verification TINYINT NOT NULL DEFAULT 1 AFTER read_receipts'), 'SELECT 1' ) FROM information_schema.columns WHERE table_schema = @im_schema AND table_name = 'im_user_privacy_settings' AND column_name = 'friend_request_verification' ); PREPARE im_stmt FROM @im_sql; EXECUTE im_stmt; DEALLOCATE PREPARE im_stmt; SET @im_schema = 'meeting_im'; SET @im_sql = ( SELECT IF( COUNT(*) = 0, CONCAT('ALTER TABLE ', @im_schema, '.im_user_privacy_settings ADD COLUMN friend_request_verification TINYINT NOT NULL DEFAULT 1 AFTER read_receipts'), 'SELECT 1' ) FROM information_schema.columns WHERE table_schema = @im_schema AND table_name = 'im_user_privacy_settings' AND column_name = 'friend_request_verification' ); PREPARE im_stmt FROM @im_sql; EXECUTE im_stmt; DEALLOCATE PREPARE im_stmt;