From 9a9a2c0742434872534fcd570de923bab0b145ba Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Thu, 20 Sep 2018 17:01:12 +0100 Subject: [PATCH] commands/create: Add version check for Postgres Server The 'jsonB' datatype was only added in v9.4 so ensure that the Postgres server to is running this or later and inform the user if this is not the case. --- wa/commands/create.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wa/commands/create.py b/wa/commands/create.py index 306cb35a..24931cfa 100644 --- a/wa/commands/create.py +++ b/wa/commands/create.py @@ -159,6 +159,8 @@ class CreateDatabaseSubcommand(SubCommand): _update_configuration_file(args, config) def create_database(self, args): + _validate_version(args) + _check_database_existence(args) _create_database_postgres(args) @@ -429,6 +431,14 @@ def touch(path): pass +def _validate_version(args): + conn = connect(user=args.username, + password=args.password, host=args.postgres_host, port=args.postgres_port) + if conn.server_version < 90400: + msg = 'Postgres version too low. Please ensure that you are using atleast v9.4' + raise CommandError(msg) + + def _check_database_existence(args): try: connect(dbname=args.dbname, user=args.username,