summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartinko2012-07-26 10:20:30 +0000
committermartinko2012-07-26 10:20:30 +0000
commit12bf78e8e35edb34dd84dd0c7d0f27ed61d434cd (patch)
tree967937376a5c60204c498f9674cd49beec889389
parent14110608cf88677ad08ee9c3144d564d0af0581d (diff)
scripts/skytools_upgrade.py: added "dry run" option and updated manual page
--not-really:: Don't actually do anything.
-rw-r--r--doc/skytools_upgrade.txt17
-rwxr-xr-xscripts/skytools_upgrade.py11
2 files changed, 20 insertions, 8 deletions
diff --git a/doc/skytools_upgrade.txt b/doc/skytools_upgrade.txt
index 3189cb78..91dda01e 100644
--- a/doc/skytools_upgrade.txt
+++ b/doc/skytools_upgrade.txt
@@ -6,7 +6,7 @@ skytools_upgrade - utility for upgrading Skytools code in databases.
== SYNOPSIS ==
- skytools_upgrade.py connstr [connstr ..]
+ skytools_upgrade.py [switches] connstr [connstr ...]
== DESCRIPTION ==
@@ -20,14 +20,21 @@ It connects to given database, then looks for following schemas:
Londiste replication.
If schema exists, its version is detected by querying .version()
-function under schema. If the function does not exists, there
-is some heiristics built in to differentiate between 2.1.4 and
-2.1.5 version of ther schemas.
+function under schema. If the function does not exists, there
+is some heuristics built in to differentiate between 2.1.4 and
+2.1.5 version of the schemas.
-If detected that version is older that current, it is upgraded
+If detected that version is older than current, it is upgraded
by applying upgrade scripts in order.
== COMMAND LINE SWITCHES ==
include::common.switches.txt[]
+Options specific to skytools_upgrade:
+
+--all::
+ Upgrade all databases.
+
+--not-really::
+ Don't actually do anything.
diff --git a/scripts/skytools_upgrade.py b/scripts/skytools_upgrade.py
index 5a1cefe4..f509b93c 100755
--- a/scripts/skytools_upgrade.py
+++ b/scripts/skytools_upgrade.py
@@ -80,6 +80,10 @@ class DbUpgrade(skytools.DBScript):
ignore[schema] = 1
continue
+ if self.options.not_really:
+ self.log.info ("%s: Would upgrade '%s' version %s to %s", dbname, schema, oldver, ver)
+ continue
+
curs = db.cursor()
curs.execute('begin')
self.log.info("%s: Upgrading '%s' version %s to %s", dbname, schema, oldver, ver)
@@ -90,7 +94,7 @@ class DbUpgrade(skytools.DBScript):
"""Loop over databases."""
self.set_single_loop(1)
-
+
self.load_cur_versions()
# loop over all dbs
@@ -152,11 +156,13 @@ class DbUpgrade(skytools.DBScript):
return self.get_database('db', connstr = cstr, autocommit = 1)
def init_optparse(self, parser=None):
- """Setup commend-line flags."""
+ """Setup command-line flags."""
p = skytools.DBScript.init_optparse(self, parser)
p.set_usage(usage)
g = optparse.OptionGroup(p, "options for skytools_upgrade")
g.add_option("--all", action="store_true", help = 'upgrade all databases')
+ g.add_option("--not-really", action = "store_true", dest = "not_really",
+ default = False, help = "don't actually do anything")
g.add_option("--user", help = 'username to use')
g.add_option("--host", help = 'hostname to use')
g.add_option("--port", help = 'port to use')
@@ -171,4 +177,3 @@ class DbUpgrade(skytools.DBScript):
if __name__ == '__main__':
script = DbUpgrade('skytools_upgrade', sys.argv[1:])
script.start()
-