summaryrefslogtreecommitdiff
path: root/alembic/templates
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-02-20 15:48:58 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-02-20 16:32:36 -0500
commitd6b0c1af3df98b50c6ec52781aa411592c4e0c32 (patch)
treeb36b324cf2578c7cc26653d1f6b6934ae19586ea /alembic/templates
parent490d9fa42b095cedb17abee17a063ee108992959 (diff)
downloadalembic-d6b0c1af3df98b50c6ec52781aa411592c4e0c32.tar.gz
Implement sys_path_prepend option
Added new config file option ``prepend_sys_path``, which is a series of paths that will be prepended to sys.path; the default value in newly generated alembic.ini files is ".". This fixes a long-standing issue where for some reason running the alembic command line would not place the local "." path in sys.path, meaning an application locally present in "." and importable through normal channels, e.g. python interpreter, pytest, etc. would not be located by Alembic, even though the ``env.py`` file is loaded relative to the current path when ``alembic.ini`` contains a relative path. Change-Id: If8f4279bd862acca44d46f4b1ab90b0a18098af3 Fixes: #797
Diffstat (limited to 'alembic/templates')
-rw-r--r--alembic/templates/generic/alembic.ini.mako4
-rw-r--r--alembic/templates/multidb/alembic.ini.mako4
-rw-r--r--alembic/templates/pylons/alembic.ini.mako4
3 files changed, 12 insertions, 0 deletions
diff --git a/alembic/templates/generic/alembic.ini.mako b/alembic/templates/generic/alembic.ini.mako
index 281794f..bf7e5d1 100644
--- a/alembic/templates/generic/alembic.ini.mako
+++ b/alembic/templates/generic/alembic.ini.mako
@@ -7,6 +7,10 @@ script_location = ${script_location}
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
+# sys.path path, will be prepended to sys.path if present.
+# defaults to the current working directory.
+prepend_sys_path = .
+
# timezone to use when rendering the date
# within the migration file as well as the filename.
# string value is passed to dateutil.tz.gettz()
diff --git a/alembic/templates/multidb/alembic.ini.mako b/alembic/templates/multidb/alembic.ini.mako
index 0b0919e..ec3c519 100644
--- a/alembic/templates/multidb/alembic.ini.mako
+++ b/alembic/templates/multidb/alembic.ini.mako
@@ -7,6 +7,10 @@ script_location = ${script_location}
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
+# sys.path path, will be prepended to sys.path if present.
+# defaults to the current working directory.
+prepend_sys_path = .
+
# timezone to use when rendering the date
# within the migration file as well as the filename.
# string value is passed to dateutil.tz.gettz()
diff --git a/alembic/templates/pylons/alembic.ini.mako b/alembic/templates/pylons/alembic.ini.mako
index 70fead0..c37397d 100644
--- a/alembic/templates/pylons/alembic.ini.mako
+++ b/alembic/templates/pylons/alembic.ini.mako
@@ -7,6 +7,10 @@ script_location = ${script_location}
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
+# sys.path path, will be prepended to sys.path if present.
+# defaults to the current working directory.
+prepend_sys_path = .
+
# timezone to use when rendering the date
# within the migration file as well as the filename.
# string value is passed to dateutil.tz.gettz()