From ebf37ace00920290a282dcb6393215266a4adef4 Mon Sep 17 00:00:00 2001 From: Madis Spiegel <95636644+SpiegelMadis@users.noreply.github.com> Date: Tue, 26 May 2026 10:48:37 +0300 Subject: [PATCH] Ordering of constraints for pg17+ Added basic ordering as PG > 17 does not allow dropping not null constraints on PK columns. --- skytools/dbstruct.py | 1 + 1 file changed, 1 insertion(+) diff --git a/skytools/dbstruct.py b/skytools/dbstruct.py index fe9a0fd..0e35f27 100644 --- a/skytools/dbstruct.py +++ b/skytools/dbstruct.py @@ -112,6 +112,7 @@ class TConstraint(TElem): c.conrelid = i.indrelid AND c.conname = (SELECT r.relname FROM pg_class r WHERE r.oid = i.indexrelid) WHERE c.conrelid = %(oid)s AND c.contype != 'f' + ORDER BY CASE c.contype WHEN 'p' THEN 1 ELSE 0 END """ table_name: str