migrate icon indicating copy to clipboard operation
migrate copied to clipboard

Structured Logging

Open mattes opened this issue 7 years ago • 1 comments

Logging output is unstructured at the moment. It would be nice to make logging a bit more sophisticated and have drivers return structured logs.

v1 tried to make this happen by allowing drivers to return a bunch of types sent over a channel, like text, error, *Migration Struct. That was a poor design choice.

Ideally we introduce an error struct with common fields. This error struct could then always be extended by the driver.

A first idea for a database error struct:

type DatabaseErr struct {
    Version int
    Identifier string
    Direction Direction
    Line uint
    Error string
    SuggestedFix string
    OrigError error
}

mattes avatar Feb 11 '17 05:02 mattes

package database now has an Error struct. https://github.com/mattes/migrate/blob/master/database/error.go

It can be further wrapped by package migrate down the road to extend it with more fields like:

Identifier string
Direction Direction

mattes avatar Feb 15 '17 07:02 mattes