fix(pgsql): strip backticks from column defaults in migration paths
Backtick-wrapped defaults (e.g. from GORM tags like `now()`) were only stripped in the CREATE TABLE column-definition path, leaving raw backticks in the ALTER COLUMN ... SET DEFAULT migration statement and in the migration-generated CREATE TABLE template, producing invalid SQL. Default-drift comparisons also compared raw values, so a backtick-wrapped model default never matched the live DB default and kept re-emitting redundant ALTER statements.
This commit is contained in:
@@ -530,7 +530,7 @@ func BuildCreateTableData(schemaName string, table *models.Table) CreateTableDat
|
||||
}
|
||||
if col.Default != nil {
|
||||
if value, ok := col.Default.(string); ok {
|
||||
colData.Default = writers.QuoteDefaultValue(value, col.Type)
|
||||
colData.Default = writers.QuoteDefaultValue(stripBackticks(value), col.Type)
|
||||
} else {
|
||||
colData.Default = fmt.Sprintf("%v", col.Default)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user