summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-28 17:42:36 +0100
committerErik Johnston <erik@matrix.org>2015-04-28 17:42:36 +0100
commitf41a9a1ffcb652c045dea5f4108984d287c6de17 (patch)
tree42c433ea28fbbb618e72997f4171c422f3d1f855 /scripts
parentEnsure we never miss any presence updates (diff)
downloadsynapse-f41a9a1ffcb652c045dea5f4108984d287c6de17.tar.xz
Add better help to scripts/port_from_sqlite_to_postgres.py
Diffstat (limited to 'scripts')
-rw-r--r--scripts/port_from_sqlite_to_postgres.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/scripts/port_from_sqlite_to_postgres.py b/scripts/port_from_sqlite_to_postgres.py
index b4ee860a92..3296f1f54f 100644
--- a/scripts/port_from_sqlite_to_postgres.py
+++ b/scripts/port_from_sqlite_to_postgres.py
@@ -671,15 +671,30 @@ class TerminalProgress(Progress):
 
 
 if __name__ == "__main__":
-    parser = argparse.ArgumentParser()
+    parser = argparse.ArgumentParser(
+        description="A script to port an existing synapse SQLite database to"
+                    " a new PostgreSQL database."
+    )
     parser.add_argument("-v", action='store_true')
-    parser.add_argument("--curses", action='store_true')
-    parser.add_argument("--sqlite-database")
     parser.add_argument(
-        "--postgres-config", type=argparse.FileType('r'),
+        "--sqlite-database", required=True,
+        help="The snapshot of the SQLite database file. This must not be"
+             " currently used by a running synapse server"
+    )
+    parser.add_argument(
+        "--postgres-config", type=argparse.FileType('r'), required=True,
+        help="The database config file for the PostgreSQL database"
+    )
+    parser.add_argument(
+        "--curses", action='store_true',
+        help="display a curses based progress UI"
     )
 
-    parser.add_argument("--batch-size", type=int, default=1000)
+    parser.add_argument(
+        "--batch-size", type=int, default=1000,
+        help="The number of rows to select from the SQLite table each"
+             " iteration [default=1000]",
+    )
 
     args = parser.parse_args()
 
@@ -705,6 +720,13 @@ if __name__ == "__main__":
 
     postgres_config = yaml.safe_load(args.postgres_config)
 
+    if "name" not in postgres_config:
+        sys.stderr.write("Malformed database config: no 'name'")
+        sys.exit(2)
+    if postgres_config["name"] != "psycopg2":
+        sys.stderr.write("Database must use 'psycopg2' connector.")
+        sys.exit(3)
+
     def start(stdscr=None):
         if stdscr:
             progress = CursesProgress(stdscr)