Figured it out:
require_once( ABSPATH . ‘wp-admin/includes/post.php’ );
$attachments = get_post_meta( $post_id, FOOGALLERY_META_ATTACHMENTS, true);
array_push($attachments,(string)$attachment_id);
update_post_meta($post_id, FOOGALLERY_META_ATTACHMENTS, $attachments);