Skip to content

Commit

Permalink
db_diff: Check for incompatible postgres version
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiefMaster committed Jan 20, 2020
1 parent 7467117 commit f073c2f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/utils/db_diff.py
Expand Up @@ -143,8 +143,13 @@ def main(dbname, verbose, reverse):
base_conn = base_eng.connect()
target_conn = target_eng.connect()

version = base_conn.execute("SELECT current_setting('server_version_num')::int").scalar()
if version < 100000:
click.echo(click.style('!! This utility requires at least Postgres 10', fg='red', bold=True), err=True)
sys.exit(1)

if verbose:
click.echo(click.style('** Calculating differences', fg='magenta', bold=True), err=True)
click.echo(click.style('** Calculating differences', fg='cyan'), err=True)
# use migra to figure out the SQL diff
m = Migration(base_conn, target_conn) if reverse else Migration(target_conn, base_conn)
m.set_safety(False)
Expand Down

0 comments on commit f073c2f

Please sign in to comment.