londiste add-table: if schema is missing, create
authorMarko Kreen <markokr@gmail.com>
Tue, 28 Apr 2009 11:45:46 +0000 (14:45 +0300)
committerMarko Kreen <markokr@gmail.com>
Tue, 28 Apr 2009 12:03:03 +0000 (15:03 +0300)
python/londiste/setup.py

index 62b2d24bf74949e44c4ce714693661230de5e646..efc14ea85c5159eb23dcba4dd02b8e9850071a4b 100644 (file)
@@ -136,6 +136,10 @@ class LondisteSetup(CascadeAdmin):
                     # table not present on provider - nowhere to get the DDL from
                     self.log.warning('Table "%s" missing on provider, skipping' % tbl)
                     return
+                schema = skytools.fq_name_parts(tbl)[0]
+                if not skytools.exists_schema(dst_curs, schema):
+                    q = "create schema %s" % skytools.quote_ident(schema)
+                    dst_curs.execute(q)
                 s = skytools.TableStruct(src_curs, tbl)
                 src_db.commit()
                 s.create(dst_curs, create_flags, log = self.log)