timshannon / badgerhold

BadgerHold is an embeddable NoSQL store for querying Go types built on Badger
MIT License
515 stars 52 forks source link

Q: Strategies for data migration? #23

Closed dhubler closed 4 years ago

dhubler commented 4 years ago

First: so glad i found badgerhold, just what i was looking for after unexplained db updates silently not working in sqlite3 when using multiple go routines.

My question: Say I remove a field in a data structure and want to migrate old data. Anyone suggest a strategy? My thought was to read data into map[string]interface{} and adjust data on application restart, but attempts to serialize into map structure gave decoder errors. I'd rather not have to maintain a "legacy data structure" of every data structure and marshal into that before unmarshalling into "official data structure"

timshannon commented 4 years ago

I assume you're using the default Gob encoding? I think the JSON encoder will be more forgiving for things like missing fields, and / or translating your values into map[string]interface{}.

I set the default as Gob so it's specifically as strict as possible, and if you want less strict handling, you can use a less strict encoder.

dhubler commented 4 years ago

i am using default encoder. i see, this is really a restriction of encoder, not badgerhold. I think we can close this then, thanks for response.