Commits

Mike Bayer committed f4366f5

--dropfirst option added, defaults to False. pre-drops tables when set to True, reportedly mis-behaves on Oracle, MS-SQL.

Comments (0)

Files changed (1)

test/testlib/config.py

     help="List available prefab dbs")
 opt("--dburi", action="store", dest="dburi",
     help="Database uri (overrides --db)")
+opt("--dropfirst", action="store_true", dest="dropfirst",
+    help="Drop all tables in the target database first (use with caution on Oracle, MS-SQL)")
 opt("--mockpool", action="store_true", dest="mockpool",
     help="Use mock pool (asserts only one connection used)")
 opt("--enginestrategy", action="callback", type="string",
 
     try:
         # also create alt schemas etc. here?
-        e = engines.utf8_engine()
-        existing = e.table_names()
-        if existing:
-            if not options.quiet:
-                print "Dropping existing tables in database: " + db_url
-                try:
-                    print "Tables: %s" % ', '.join(existing)
-                except:
-                    pass
-                print "Abort within 5 seconds..."
-                time.sleep(5)
-            md = schema.MetaData(e, reflect=True)
-            md.drop_all()
-        e.dispose()
+        if options.dropfirst:
+            e = engines.utf8_engine()
+            existing = e.table_names()
+            if existing:
+                if not options.quiet:
+                    print "Dropping existing tables in database: " + db_url
+                    try:
+                        print "Tables: %s" % ', '.join(existing)
+                    except:
+                        pass
+                    print "Abort within 5 seconds..."
+                    time.sleep(5)
+                md = schema.MetaData(e, reflect=True)
+                md.drop_all()
+            e.dispose()
     except (KeyboardInterrupt, SystemExit):
         raise
     except Exception, e:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.