diff --git a/cmd/ormat/command/helper.go b/cmd/ormat/command/helper.go index 728bbd0..ae14b31 100644 --- a/cmd/ormat/command/helper.go +++ b/cmd/ormat/command/helper.go @@ -3,7 +3,6 @@ package command import ( "context" "errors" - "fmt" "log/slog" "net/url" "os" diff --git a/driver/mysql/sql.go b/driver/mysql/sql.go index 43cad4a..ca50ac7 100644 --- a/driver/mysql/sql.go +++ b/driver/mysql/sql.go @@ -102,9 +102,16 @@ func parseSqlColumnDefinition(col *sqlparser.ColumnDefinition) (*schema.Column, if colType.Default != nil { coldef.Default = &schema.Literal{V: string(colType.Default.Val)} } + if colType.OnUpdate != nil { + coldef.AddAttrs(&mysql.OnUpdate{ + Attr: nil, + A: string(colType.OnUpdate.Val), + }) + } if colType.Autoincrement { coldef.AddAttrs(&mysql.AutoIncrement{}) } + if colType.Comment != nil { coldef.AddAttrs(&schema.Comment{Text: string(colType.Comment.Val)}) } diff --git a/driver/mysql/sql_tidb.go b/driver/mysql/sql_tidb.go index 99792ae..64f5b63 100644 --- a/driver/mysql/sql_tidb.go +++ b/driver/mysql/sql_tidb.go @@ -108,6 +108,11 @@ func parserCreateTableStmtColumn(col *ast.ColumnDef) (*schema.Column, error) { case ast.ColumnOptionComment: coldef.AddAttrs(&schema.Comment{Text: strings.Trim(formatExprNode(opt.Expr), `"`)}) + case ast.ColumnOptionOnUpdate: + coldef.AddAttrs(&mysql.OnUpdate{ + Attr: nil, + A: strings.Trim(formatExprNode(opt.Expr), `"`), + }) } }