dialects/postgres.go aktualisiert

Fix migrations for cocktoachdb not working because of recreation of tables that are defined with "pk autoincr". Cockroach only creates the rowid with default unique_rowid() when no pk is defined.

Signed-off-by: LNAhri <lnahri@noreply.gitea.com>
This commit is contained in:
LNAhri 2025-02-26 15:00:43 +00:00
parent 7654b7b749
commit b6b451420b
1 changed files with 5 additions and 1 deletions

View File

@ -1145,7 +1145,11 @@ WHERE n.nspname= s.table_schema AND c.relkind = 'r' AND c.relname = $1%s AND f.a
} }
if colDefault != nil && *colDefault == "unique_rowid()" { // ignore the system column added by cockroach if colDefault != nil && *colDefault == "unique_rowid()" { // ignore the system column added by cockroach
continue if colName == "rowid" { // but only skip if the name is also rowid therefore allowing custom primary keys columns and don't recreate tables defined with with pk autoincr
continue
}
te := ""
colDefault = &te
} }
col.Name = strings.Trim(colName, `" `) col.Name = strings.Trim(colName, `" `)