dbstruct: Remove ONLY from ADD CONSTRAINT.
authorMarko Kreen <markokr@gmail.com>
Wed, 28 Oct 2009 13:34:27 +0000 (15:34 +0200)
committerMarko Kreen <markokr@gmail.com>
Tue, 3 Nov 2009 12:43:44 +0000 (14:43 +0200)
Parent table cannot have contraints that the childs do not have.

python/skytools/dbstruct.py

index 916de13152d0b0872bd3584298ca912f0a6c662e..8e55903618e3105eaff4e49db42acd77caeaef79 100644 (file)
@@ -93,7 +93,9 @@ class TConstraint(TElem):
 
     def get_create_sql(self, curs, new_table_name=None):
         """Generate creation SQL."""
-        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'):