refactor(stats): slim final daily mileage table
This commit is contained in:
@@ -72,7 +72,7 @@ func (w *Writer) EnsureSchema(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
for _, statement := range DailyMileageAlterSQL {
|
||||
if _, err := w.exec.ExecContext(ctx, statement); err != nil && !isDuplicateColumnError(err) {
|
||||
if _, err := w.exec.ExecContext(ctx, statement); err != nil && !isIgnorableSchemaChangeError(err) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -284,12 +284,17 @@ func sourceKey(env envelope.FrameEnvelope) string {
|
||||
return SourceKey(env.Protocol, env.Phone, env.DeviceID, NormalizeSourceIP(env.SourceEndpoint))
|
||||
}
|
||||
|
||||
func isDuplicateColumnError(err error) bool {
|
||||
func isIgnorableSchemaChangeError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
text := strings.ToLower(err.Error())
|
||||
return strings.Contains(text, "duplicate column") || strings.Contains(text, "1060")
|
||||
return strings.Contains(text, "duplicate column") ||
|
||||
strings.Contains(text, "1060") ||
|
||||
strings.Contains(text, "duplicate key name") ||
|
||||
strings.Contains(text, "1061") ||
|
||||
strings.Contains(text, "can't drop") ||
|
||||
strings.Contains(text, "1091")
|
||||
}
|
||||
|
||||
type mileageFieldMapping struct {
|
||||
|
||||
Reference in New Issue
Block a user