How to properly update content via DB

Hi, I want to update some content via DB, what is correct procedure after applying changes in database? So far from testing I got mixed results. I updated textValue in [umbracoPropertyData] table for one of the properties then I tried to rebuild database cache via backoffice and delete umbraco/Data/TEMP/NuCache and restart the site, trying these things didn’t always result on content being updated for the property. What is “correct“ way of doing this?

I doubt there is a correct way of doing it, lol! But I think it would help if you tell us why you want to do this.

I wanted to send CSV created by SQL query with a lot of properties that need to be translated to external team. This way I could easily import them back via SQL using same CSV but with translated properties.

So far I have found that this seem to give same result everytime:

  1. Update DB
    update [umbracoPropertyData]
    set textValue = ‘…’
    where id = 2666026
  2. Cold restart of site
  3. Force republish for the nodes:
    IContent? content = _contentService.GetById(...);
    _contentService.SaveAndPublishBranch(content, PublishBranchFilter.All)

Could this be ok or should I find different approach?

There is no “correct” way of directly editing data the Umbraco database and it’s not recommended - it’s usually a bad idea.

I can see your appraoch working, but be very careful.

I notice that you are using the IContentService - that is the correct way to edit Umbraco content programmatically.

Have you looked at Translation Manager? It’s a great tool for doing exactly what you need WRT translations and if you’re using a translation service that uses Xliff (or one of the other connectors) you could save yourself a lot of time/energy/money.

Depends if this is a one time translation job or something ongoing but in the past I’ve built a protected page, only accessible to certain member types (e.g. they login) that basically queries the translations / pages that need some text update - and then have an ajax update that hits the content service and updates the content.

More work than an export / import but if it’s ongoing updates this might be worth the effort and allows for more self-sevice.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.