go-bond/bond

Prevent unintended schema changes

Opened this issue · 0 comments

It may happen that types used by bond.Table[T] change. The current bond version does not have any protection against that.

To make the situation a little bit better we could use https://github.com/fatih/structs to dump all of the T field names and types and store them in pebble. We could do that in bond.NewTable and verify if the schemas match. If don't we could return an error: schema mismatch for table: %d.

This would cover only part of the schema which are rows. We still need to handle PrimaryKey / Indexes. We could try to serialize them into something that can be compared as well.

Lastly, we need to make sure that everything serializes in the same way. This can be done by generating a random row serializing it and then comparing it.

The mechanism for schema update shall be provided in the Migration framework. I can't see any temporary shortcuts for that.