Remove ONLY from ADD CONSTRAINT.
authorMarko Kreen <markokr@gmail.com>
Fri, 23 Oct 2009 12:01:55 +0000 (12:01 +0000)
committerMarko Kreen <markokr@gmail.com>
Fri, 23 Oct 2009 12:01:55 +0000 (12:01 +0000)
Parent table cannot have contraints that the childs do not have.

python/skytools/dbstruct.py

index 41af18f133e6d510906d725ec64a05f235533826..a64316f8fbd32adcb80216767025b846c5d3484d 100644 (file)
@@ -89,7 +89,9 @@ class TConstraint(TElem):
             self.type += T_PKEY
 
     def get_create_sql(self, curs, new_table_name=None):
-        fmt = "ALTER TABLE ONLY %s ADD CONSTRAINT %s %s;"
+        # no ONLY here as table with childs (only case that matters)
+        # cannot have contraints that childs do not have
+        fmt = "ALTER TABLE %s ADD CONSTRAINT %s %s;"
         if new_table_name:
             name = self.name
             if self.contype in ('p', 'u'):