1
1
mirror of https://github.com/yandex/pgmigrate.git synced 2024-09-20 00:31:17 +03:00

Skip unnecessary schema creation on init

This commit is contained in:
secwall 2021-07-10 00:30:14 +03:00
parent a27fb3318b
commit a01b512b68

View File

@ -385,6 +385,12 @@ def _init_schema(schema, cursor):
""" """
Create schema_version table Create schema_version table
""" """
cursor.execute(
'SELECT EXISTS(SELECT 1 FROM '
'information_schema.schemata '
'WHERE schema_name = %s)', (schema, ))
schema_exists = cursor.fetchone()[0]
if not schema_exists:
LOG.info('creating schema') LOG.info('creating schema')
cursor.execute( cursor.execute(
SQL('CREATE SCHEMA IF NOT EXISTS {schema}').format( SQL('CREATE SCHEMA IF NOT EXISTS {schema}').format(