`source_attachment_id` = #{sourceAttachmentId} AND `source_mongo_id` = #{sourceMongoId} AND `request_width` = #{requestWidth} AND `request_height` = #{requestHeight} AND `fit_mode` = #{fitMode} AND `output_format` = #{outputFormat} AND `algorithm_version` = #{algorithmVersion} INSERT INTO `attachment_variant` ( `id`, `source_attachment_id`, `source_mongo_id`, `source_md5`, `request_width`, `request_height`, `fit_mode`, `output_format`, `algorithm_version`, `mongo_id`, `name`, `mime_type`, `metadata`, `size`, `md5`, `created_at`, `expire_at` ) VALUES ( #{id}, #{sourceAttachmentId}, #{sourceMongoId}, #{sourceMd5}, #{requestWidth}, #{requestHeight}, #{fitMode}, #{outputFormat}, #{algorithmVersion}, #{mongoId}, #{name}, #{mimeType}, #{metadata}, #{size}, #{md5}, #{createdAt}, #{expireAt} ) UPDATE `attachment_variant` SET `expire_at` = #{expireAt} WHERE `id` = #{id} AND `expire_at` > #{now} DELETE FROM `attachment_variant` WHERE `id` = #{id}