londiste: change behaviour of --create* flags
authorMarko Kreen <markokr@gmail.com>
Mon, 24 Jan 2011 13:28:21 +0000 (15:28 +0200)
committerMarko Kreen <markokr@gmail.com>
Mon, 24 Jan 2011 15:28:51 +0000 (17:28 +0200)
--create now does minimal pkey-only structure

--create-full does maximal structure

--create-only is dropped as too complex

python/londiste.py
python/londiste/setup.py
tests/londiste/regen.sh

index 7b3b4a97fc7aa285aa869a8728554e0ba6ea1006..5a852da2ab8b545bf91357b3153ab4bee5d84632 100755 (executable)
@@ -113,9 +113,9 @@ class Londiste(skytools.DBScript):
         g.add_option("--skip-truncate", action="store_true", dest="skip_truncate",
                 help = "add: keep old data", default=False)
         g.add_option("--create", action="store_true",
-                help = "add: create table/seq if not exist")
-        g.add_option("--create-only",
-                help = "add: create table/seq if not exist (seq,pkey,full,indexes,fkeys)")
+                help = "add: create table/seq if not exist, with minimal schema")
+        g.add_option("--create-full", action="store_true",
+                help = "add: create table/seq if not exist, with full schema")
         g.add_option("--trigger-flags",
                 help="add: Set trigger flags (BAIUDLQ)")
         g.add_option("--trigger-arg", action="append",
index e3d87de732c31040b5730c70ad5611aa1663f128..a2b4c899382a5e398cc6c674ff01f95f02c4e4e0 100644 (file)
@@ -53,9 +53,9 @@ class LondisteSetup(CascadeAdmin):
         p.add_option("--all", action="store_true",
                     help="include all tables", default=False)
         p.add_option("--create", action="store_true",
-                    help="include all tables", default=False)
-        p.add_option("--create-only",
-                    help="pkey,fkeys,indexes")
+                    help="create, minimal", default=False)
+        p.add_option("--create-full", action="store_true",
+                    help="create, full")
         p.add_option("--trigger-flags",
                     help="Set trigger flags (BAIUDLQ)")
         p.add_option("--trigger-arg", action="append",
@@ -121,21 +121,12 @@ class LondisteSetup(CascadeAdmin):
             sys.exit(1)
 
         # pick proper create flags
-        create = self.options.create_only
-        if not create and self.options.create:
-            create = 'full'
-
-        fmap = {
-            "full": skytools.T_ALL,
-            "pkey": skytools.T_PKEY,
-        }
-        create_flags = 0
-        if create:
-            create_flags = skytools.T_TABLE
-            for f in create.split(','):
-                if f not in fmap:
-                    raise Exception("bad --create-only flag: " + f)
-                create_flags |= fmap[f]
+        if self.options.create_full:
+            create_flags = skytools.T_ALL
+        elif self.options.create:
+            create_flags = skytools.T_TABLE | skytools.T_PKEY
+        else:
+            create_flags = 0
 
         # seems ok
         for tbl in args:
@@ -244,19 +235,12 @@ class LondisteSetup(CascadeAdmin):
         args = self.expand_arg_list(dst_db, 'S', False, args)
 
         # pick proper create flags
-        create = self.options.create_only
-        if not create and self.options.create:
-            create = 'full'
-
-        fmap = {
-            "full": skytools.T_SEQUENCE,
-        }
-        create_flags = 0
-        if create:
-            for f in create.split(','):
-                if f not in fmap:
-                    raise Exception("bad --create-only flag: " + f)
-                create_flags += fmap[f]
+        if self.options.create_full:
+            create_flags = skytools.T_SEQUENCE
+        elif self.options.create:
+            create_flags = skytools.T_SEQUENCE
+        else:
+            create_flags = 0
 
         # seems ok
         for seq in args:
index 770a7ed57f7bbff6b93abcf684581799fb60a2ec..17db15066aae2f3d687c850b57bc558f60a239a4 100755 (executable)
@@ -96,14 +96,14 @@ msg "Register table on other node with creation"
 for db in db2 db3 db4 db5; do
   run psql -d $db -c "create sequence mytable_id_seq"
   run londiste3 $v conf/londiste_db1.ini add-seq mytable_id_seq
-  run londiste3 $v conf/londiste_$db.ini add-table mytable --create
+  run londiste3 $v conf/londiste_$db.ini add-table mytable --create-full
 done
 
 msg "Register another table to test unregistration"
 run psql -d db1 -c "create table mytable2 (id int4 primary key, data text)"
 run londiste3 $v conf/londiste_db1.ini add-table mytable2
 for db in db2 db3 db4 db5; do
-  run londiste3 $v conf/londiste_$db.ini add-table mytable2 --create-only=pkey
+  run londiste3 $v conf/londiste_$db.ini add-table mytable2 --create
 done
 
 msg "Wait until tables are in sync on db5"