1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 12:06:08 +00:00

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.
This commit is contained in:
Marc Bonnici 2018-09-20 17:01:12 +01:00
parent 57aa5ca588
commit 9a9a2c0742

View File

@ -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,