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:
@@ -512,7 +512,7 @@ func formatColumnDefaultSQL(col *models.Column) (setDefault bool, defaultVal str
|
||||
return false, ""
|
||||
}
|
||||
if value, ok := col.Default.(string); ok {
|
||||
return true, writers.QuoteDefaultValue(value, col.Type)
|
||||
return true, writers.QuoteDefaultValue(stripBackticks(value), col.Type)
|
||||
}
|
||||
return true, fmt.Sprintf("%v", col.Default)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user