From b6b451420b56f99cb0c88f0e3e1d88fcd3e42ab3 Mon Sep 17 00:00:00 2001 From: LNAhri Date: Wed, 26 Feb 2025 15:00:43 +0000 Subject: [PATCH] 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 --- dialects/postgres.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dialects/postgres.go b/dialects/postgres.go index 6e379583..df262614 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -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 - 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, `" `)