From: Mike Bayer Date: Sat, 26 Jul 2014 00:19:06 +0000 (-0400) Subject: - use a template database for PG so extensions get created automatically X-Git-Tag: rel_1_0_0b1~277 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e602a731974bface5c25ff4e83e7e2bd153daa61;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - use a template database for PG so extensions get created automatically --- diff --git a/lib/sqlalchemy/testing/plugin/provision.py b/lib/sqlalchemy/testing/plugin/provision.py index d665727f16..e6790f877f 100644 --- a/lib/sqlalchemy/testing/plugin/provision.py +++ b/lib/sqlalchemy/testing/plugin/provision.py @@ -1,5 +1,6 @@ from sqlalchemy.engine import url as sa_url + def create_follower_db(follower_ident): from .. import config, engines @@ -7,6 +8,9 @@ def create_follower_db(follower_ident): hosts = set() + for cfg in config.Config.all_configs(): + cfg.db.dispose() + for cfg in config.Config.all_configs(): url = cfg.db.url backend = url.get_backend_name() @@ -40,13 +44,12 @@ def _pg_create_db(eng, ident): conn.execute("DROP DATABASE %s" % ident) except: pass - conn.execute("CREATE DATABASE %s" % ident) + currentdb = conn.scalar("select current_database()") + conn.execute("CREATE DATABASE %s TEMPLATE %s" % (ident, currentdb)) def _pg_init_db(eng): - with eng.connect() as conn: - conn.execute("CREATE SCHEMA test_schema") - conn.execute("CREATE SCHEMA test_schema_2") + pass def _mysql_create_db(eng, ident):