deleteTagDB :: CommentId -> TagId -> DB ()
deleteTagDB comment_id tag_id = do
    delete $ from $ \ct ->
        where_ $ ct ^. CommentTagComment ==. val comment_id
             &&. ct ^. CommentTagTag     ==. val tag_id
    exists_ct <- selectExists $ from $ \ct ->
                    where_ $ ct ^. CommentTagTag ==. val tag_id
    exists_pt <- selectExists $ from $ \pt ->
                     where_ $ pt ^. ProjectTagTag ==. val tag_id
    exists_tc <- selectExists $ from $ \tc ->
                     where_ $ tc ^. TagColorTag ==. val tag_id
    exists_dtc <- selectExists $ from $ \dtc ->
                      where_ $ dtc ^. DefaultTagColorTag ==. val tag_id
    unless (exists_ct || exists_pt || exists_tc || exists_dtc) $
        delete $ from $ \t ->
            where_ $ t ^. TagId ==. val tag_id
deleteTagDB :: CommentId -> TagId -> DB ()
deleteTagDB comment_id tag_id = do
    delete $ from $ \ct ->
        where_ $ ct ^. CommentTagComment ==. val comment_id
             &&. ct ^. CommentTagTag     ==. val tag_id
    exists_ct <- selectExists $ from $ \ct ->
                    where_ $ ct ^. CommentTagTag ==. val tag_id
    exists_pt <- selectExists $ from $ \pt ->
                     where_ $ pt ^. ProjectTagTag ==. val tag_id
    exists_tc <- selectExists $ from $ \tc ->
                     where_ $ tc ^. TagColorTag ==. val tag_id
    exists_dtc <- selectExists $ from $ \dtc ->
                      where_ $ dtc ^. DefaultTagColorTag ==. val tag_id
    unless (exists_ct || exists_pt || exists_tc || exists_dtc) $
        delete $ from $ \t ->
            where_ $ t ^. TagId ==. val tag_id
deleteTagDB comment_id tag_id = do
    delete $ from $ \ct ->
        where_ $ ct ^. CommentTagComment ==. val comment_id
             &&. ct ^. CommentTagTag     ==. val tag_id
    exists_ct <- selectExists $ from $ \ct ->
                    where_ $ ct ^. CommentTagTag ==. val tag_id
    exists_pt <- selectExists $ from $ \pt ->
                     where_ $ pt ^. ProjectTagTag ==. val tag_id
    exists_tc <- selectExists $ from $ \tc ->
                     where_ $ tc ^. TagColorTag ==. val tag_id
    exists_dtc <- selectExists $ from $ \dtc ->
                      where_ $ dtc ^. DefaultTagColorTag ==. val tag_id
    unless (exists_ct || exists_pt || exists_tc || exists_dtc) $
        delete $ from $ \t ->
            where_ $ t ^. TagId ==. val tag_id