3 ms·
"What if you need to query based on the site_data?" "What about updating the data? You need to get the object and then you need to parse it, change it and send
by kisstheblade 11y ago
"What if you need to query based on the site_data?"
"What about updating the data? You need to get the object and then you need to parse it, change it and send it back marshalled to TEXT that MySQL can understand."
I implemented something similar, with db columns extracted from the json data to be used in querying.
I have a "schema_version" column and property in the API, and a migration class which checks the versions of the stored objects, and if the current schema version is greater then runs the needed migrations (a "migration" in this case is extracting some new columns from the data).
Having a schema version probably handles your other case also.
Yes, running the migration can of course take some time depending on your data, but if you update one row at a time then you don't even have to have service interruptions (the old schema version rows just don't eg. get found in queries using the new fields until updated).