Bulk update DB records – Symfony – Migrations

I have below JSON data in the user table opt column in mysql database

{
  "lp": "xxx",
  "ip": 5,
  "opt": [1, 2, 3]
}

And now I want to change the data in that column to

{
  "lp": "xxx",
  "ip": 5,
  "opt": {
    "opt1": [1, 2],
    "opt2": [1, 4, 5]
  }
}

So I’m thinking of using migrations and by using entity manager bulk update it as like this https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/batch-processing.html#iterating-results

And I’m having a issue with how to get the instance of a EntityManager in to the migration class

Or is there a better approach to do this?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *