From c44e147a9fc5c020036ea68ba854c211e489ae06 Mon Sep 17 00:00:00 2001 From: DacongDA Date: Wed, 21 Feb 2024 19:57:01 +0800 Subject: [PATCH] feat: support modify the varchar type column of postgresql database in sync function --- sync.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sync.go b/sync.go index adc2d859..4c02257b 100644 --- a/sync.go +++ b/sync.go @@ -168,7 +168,8 @@ func (session *Session) SyncWithOptions(opts SyncOptions, beans ...interface{}) tbNameWithSchema, col.Name, curType, expectedType) } } else if strings.HasPrefix(curType, schemas.Varchar) && strings.HasPrefix(expectedType, schemas.Varchar) { - if engine.dialect.URI().DBType == schemas.MYSQL { + if engine.dialect.URI().DBType == schemas.POSTGRES || + engine.dialect.URI().DBType == schemas.MYSQL { if oriCol.Length < col.Length { engine.logger.Infof("Table %s column %s change type from varchar(%d) to varchar(%d)\n", tbNameWithSchema, col.Name, oriCol.Length, col.Length) @@ -184,7 +185,8 @@ func (session *Session) SyncWithOptions(opts SyncOptions, beans ...interface{}) } } } else if expectedType == schemas.Varchar { - if engine.dialect.URI().DBType == schemas.MYSQL { + if engine.dialect.URI().DBType == schemas.POSTGRES || + engine.dialect.URI().DBType == schemas.MYSQL { if oriCol.Length < col.Length { engine.logger.Infof("Table %s column %s change type from varchar(%d) to varchar(%d)\n", tbNameWithSchema, col.Name, oriCol.Length, col.Length)