mirror of
https://github.com/yandex/pgmigrate.git
synced 2024-09-19 16:17:24 +03:00
Skip unnecessary schema creation on init
This commit is contained in:
parent
a27fb3318b
commit
a01b512b68
12
pgmigrate.py
12
pgmigrate.py
@ -385,10 +385,16 @@ def _init_schema(schema, cursor):
|
|||||||
"""
|
"""
|
||||||
Create schema_version table
|
Create schema_version table
|
||||||
"""
|
"""
|
||||||
LOG.info('creating schema')
|
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
SQL('CREATE SCHEMA IF NOT EXISTS {schema}').format(
|
'SELECT EXISTS(SELECT 1 FROM '
|
||||||
schema=Identifier(schema)))
|
'information_schema.schemata '
|
||||||
|
'WHERE schema_name = %s)', (schema, ))
|
||||||
|
schema_exists = cursor.fetchone()[0]
|
||||||
|
if not schema_exists:
|
||||||
|
LOG.info('creating schema')
|
||||||
|
cursor.execute(
|
||||||
|
SQL('CREATE SCHEMA IF NOT EXISTS {schema}').format(
|
||||||
|
schema=Identifier(schema)))
|
||||||
LOG.info('creating type schema_version_type')
|
LOG.info('creating type schema_version_type')
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
SQL('CREATE TYPE {schema}.schema_version_type '
|
SQL('CREATE TYPE {schema}.schema_version_type '
|
||||||
|
Loading…
Reference in New Issue
Block a user