diff --git a/alembic/command.py b/alembic/command.py index d48affc7..bbff75d1 100644 --- a/alembic/command.py +++ b/alembic/command.py @@ -29,7 +29,7 @@ def list_templates(config): with open( os.path.join(config.get_template_directory(), tempname, "README") ) as readme: - synopsis = next(readme) + synopsis = next(readme).rstrip() config.print_stdout("%s - %s", tempname, synopsis) config.print_stdout("\nTemplates are used via the 'init' command, e.g.:") diff --git a/alembic/templates/pylons/README b/alembic/templates/pylons/README deleted file mode 100644 index ed3c28ee..00000000 --- a/alembic/templates/pylons/README +++ /dev/null @@ -1 +0,0 @@ -Configuration that reads from a Pylons project environment. \ No newline at end of file diff --git a/alembic/templates/pylons/alembic.ini.mako b/alembic/templates/pylons/alembic.ini.mako deleted file mode 100644 index 82facf91..00000000 --- a/alembic/templates/pylons/alembic.ini.mako +++ /dev/null @@ -1,71 +0,0 @@ -# a Pylons configuration. - -[alembic] -# path to migration scripts -script_location = ${script_location} - -# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s -# Uncomment the line below if you want the files to be prepended with date and time -# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file -# for all available tokens -# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(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. -# If specified, requires the python-dateutil library that can be -# installed by adding `alembic[tz]` to the pip requirements -# string value is passed to dateutil.tz.gettz() -# leave blank for localtime -# timezone = - -# max length of characters to apply to the -# "slug" field -# truncate_slug_length = 40 - -# set to 'true' to run the environment during -# the 'revision' command, regardless of autogenerate -# revision_environment = false - -# set to 'true' to allow .pyc and .pyo files without -# a source .py file to be detected as revisions in the -# versions/ directory -# sourceless = false - -# version location specification; This defaults -# to ${script_location}/versions. When using multiple version -# directories, initial revisions must be specified with --version-path. -# The path separator used here should be the separator specified by "version_path_separator" below. -# version_locations = %(here)s/bar:%(here)s/bat:${script_location}/versions - -# version path separator; As mentioned above, this is the character used to split -# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep. -# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas. -# Valid values for version_path_separator are: -# -# version_path_separator = : -# version_path_separator = ; -# version_path_separator = space -version_path_separator = os # Use os.pathsep. Default configuration used for new projects. - -# the output encoding used when revision files -# are written from script.py.mako -# output_encoding = utf-8 - -[post_write_hooks] -# post_write_hooks defines scripts or Python functions that are run -# on newly generated revision scripts. See the documentation for further -# detail and examples - -# format using "black" - use the console_scripts runner, against the "black" entrypoint -# hooks = black -# black.type = console_scripts -# black.entrypoint = black -# black.options = -l 79 REVISION_SCRIPT_FILENAME - -pylons_config_file = ./development.ini - -# that's it ! diff --git a/alembic/templates/pylons/env.py b/alembic/templates/pylons/env.py deleted file mode 100644 index 99bc19ef..00000000 --- a/alembic/templates/pylons/env.py +++ /dev/null @@ -1,86 +0,0 @@ -"""Pylons bootstrap environment. - -Place 'pylons_config_file' into alembic.ini, and the application will -be loaded from there. - -""" -from logging.config import fileConfig - -from paste.deploy import loadapp - -from alembic import context - - -try: - # if pylons app already in, don't create a new app - from pylons import config as pylons_config - - pylons_config["__file__"] -except: - config = context.config - # can use config['__file__'] here, i.e. the Pylons - # ini file, instead of alembic.ini - config_file = config.get_main_option("pylons_config_file") - if config_file is not None: - fileConfig(config_file) - wsgi_app = loadapp("config:%s" % config_file, relative_to=".") - - -# customize this section for non-standard engine configurations. -meta = __import__( - "%s.model.meta" % wsgi_app.config["pylons.package"] -).model.meta - -# add your model's MetaData object here -# for 'autogenerate' support -# from myapp import mymodel -# target_metadata = mymodel.Base.metadata -target_metadata = None - - -def run_migrations_offline() -> None: - """Run migrations in 'offline' mode. - - This configures the context with just a URL - and not an Engine, though an Engine is acceptable - here as well. By skipping the Engine creation - we don't even need a DBAPI to be available. - - Calls to context.execute() here emit the given string to the - script output. - - """ - context.configure( - url=meta.engine.url, - target_metadata=target_metadata, - literal_binds=True, - dialect_opts={"paramstyle": "named"}, - ) - with context.begin_transaction(): - context.run_migrations() - - -def run_migrations_online() -> None: - """Run migrations in 'online' mode. - - In this scenario we need to create an Engine - and associate a connection with the context. - - """ - # specify here how the engine is acquired - # engine = meta.engine - raise NotImplementedError("Please specify engine connectivity here") - - with engine.connect() as connection: # noqa - context.configure( - connection=connection, target_metadata=target_metadata - ) - - with context.begin_transaction(): - context.run_migrations() - - -if context.is_offline_mode(): - run_migrations_offline() -else: - run_migrations_online() diff --git a/alembic/templates/pylons/script.py.mako b/alembic/templates/pylons/script.py.mako deleted file mode 100644 index 55df2863..00000000 --- a/alembic/templates/pylons/script.py.mako +++ /dev/null @@ -1,24 +0,0 @@ -"""${message} - -Revision ID: ${up_revision} -Revises: ${down_revision | comma,n} -Create Date: ${create_date} - -""" -from alembic import op -import sqlalchemy as sa -${imports if imports else ""} - -# revision identifiers, used by Alembic. -revision = ${repr(up_revision)} -down_revision = ${repr(down_revision)} -branch_labels = ${repr(branch_labels)} -depends_on = ${repr(depends_on)} - - -def upgrade() -> None: - ${upgrades if upgrades else "pass"} - - -def downgrade() -> None: - ${downgrades if downgrades else "pass"} diff --git a/docs/build/front.rst b/docs/build/front.rst index 547a60d9..f4eb660b 100644 --- a/docs/build/front.rst +++ b/docs/build/front.rst @@ -93,11 +93,10 @@ Community ========= Alembic is developed by `Mike Bayer `_, and is -loosely associated with the SQLAlchemy_, `Pylons `_, -and `Openstack `_ projects. +part of the SQLAlchemy_ project. -User issues, discussion of potential bugs and features should be posted -to the Alembic Google Group at `sqlalchemy-alembic `_. +User issues, discussion of potential bugs and features are most easily +discussed using `Github Discussions `_. .. _bugs: diff --git a/docs/build/tutorial.rst b/docs/build/tutorial.rst index 17034c16..8540be13 100644 --- a/docs/build/tutorial.rst +++ b/docs/build/tutorial.rst @@ -108,11 +108,12 @@ command:: generic - Generic single-database configuration. async - Generic single-database configuration with an async dbapi. multidb - Rudimentary multi-database configuration. - pylons - Configuration that reads from a Pylons project environment. Templates are used via the 'init' command, e.g.: - alembic init --template pylons ./scripts + alembic init --template generic ./scripts + +.. versionchanged:: 1.8 The "pylons" environment template has been removed. Editing the .ini File ===================== diff --git a/docs/build/unreleased/764.rst b/docs/build/unreleased/764.rst index 184c0ac7..9be4a967 100644 --- a/docs/build/unreleased/764.rst +++ b/docs/build/unreleased/764.rst @@ -2,5 +2,6 @@ :tags: feature, typing :tickets: 764 - Adds typing annotations to ``env.py`` and migration templates. - Pull request by Nikita Sobolev. + :pep:`484` typing annotations have been added to the ``env.py`` and + revision template files within migration templates. Pull request by Nikita + Sobolev. diff --git a/docs/build/unreleased/987.rst b/docs/build/unreleased/987.rst new file mode 100644 index 00000000..c9d70556 --- /dev/null +++ b/docs/build/unreleased/987.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: changed, environment + :tickets: 987 + + The "Pylons" environment template has been removed as of Alembic 1.8. This + template was based on the very old pre-Pyramid Pylons web framework which + has been long superseded by Pyramid.