Releases: sqlalchemy/alembic
1.7.0
1.7.0
Released: August 30, 2021
changed
-
[changed] [installation] Alembic 1.7 now supports Python 3.6 and above; support for prior versions
including Python 2.7 has been dropped. -
[changed] [installation] Make the
python-dateutil
library an optional dependency.
This library is only required if thetimezone
option
is used in the Alembic configuration.
An extra require namedtz
is available with
pip install alembic[tz]
to install it.References: #674
-
[changed] [installation] The dependency on
pkg_resources
which is part ofsetuptools
has
been removed, so there is no longer any runtime dependency on
setuptools
. The functionality has been replaced with
importlib.metadata
andimportlib.resources
which are both part of
Python std.lib, or via pypy dependencyimportlib-metadata
for Python
version < 3.8 andimportlib-resources
for Python version < 3.9
(while importlib.resources was added to Python in 3.7, it did not include
the "files" API until 3.9).References: #885
feature
-
[feature] [environment] Enhance
version_locations
parsing to handle paths containing spaces.
The new configuration optionversion_path_separator
specifies the
character to use when splitting theversion_locations
string. The
default for new configurations isversion_path_separator = os
,
which will useos.pathsep
(e.g.,;
on Windows).References: #842
-
[feature] [tests] Created a "test suite" similar to the one for SQLAlchemy, allowing
developers of third-party dialects to test their code against a set of
Alembic tests that have been specially selected to exercise
back-end database operations. At the time of release,
third-party dialects that have adopted the Alembic test suite to verify
compatibility include
CockroachDB and
SAP ASE (Sybase).References: #855
-
[feature] [general] pep-484 type annotations have been added throughout the library.
Additionally, stub .pyi files have been added for the "dynamically"
generated Alembic modulesalembic.op
andalembic.config
, which
include complete function signatures and docstrings, so that the functions
in these namespaces will have both IDE support (vscode, pycharm, etc) as
well as support for typing tools like Mypy. The files themselves are
statically generated from their source functions within the source tree.
usecase
-
[usecase] [batch] Named CHECK constraints are now supported by batch mode, and will
automatically be part of the recreated table assuming they are named. They
also can be explicitly dropped usingop.drop_constraint()
. For
"unnamed" CHECK constraints, these are still skipped as they cannot be
distinguished from the CHECK constraints that are generated by the
Boolean
andEnum
datatypes.Note that this change may require adjustments to migrations that drop or
rename columns which feature an associated named check constraint, such
that an additionalop.drop_constraint()
directive should be added for
that named constraint as there will no longer be an associated column
for it; for theBoolean
andEnum
datatypes, anexisting_type
keyword may be passed toBatchOperations.drop_constraint
as well.References: #884
bug
-
[bug] [operations] Fixed regression due to #803 where the
.info
and.comment
attributes ofTable
would be lost inside of theDropTableOp
class, which when "reversed" into aCreateTableOp
would then have
lost these elements. Pull request courtesy Nicolas CANIART.References: #879
-
[bug] [batch] [sqlite] Batch "auto" mode will now select for "recreate" if the
add_column()
operation is used on SQLite, and the column itself meets the criteria for
SQLite where ADD COLUMN is not allowed, in this case a functional or
parenthesized SQL expression or aComputed
(i.e. generated) column.References: #883
-
[bug] [commands] Re-implemented the
python-editor
dependency as a small internal
function to avoid the need for external dependencies.References: #856
-
[bug] [postgresql] Fixed issue where usage of the PostgreSQL
postgresql_include
option
within aOperations.create_index()
would raise a KeyError, as the
additional column(s) need to be added to the table object used by the
construct internally. The issue is equivalent to the SQL Server issue fixed
in #513. Pull request courtesy Steven Bronson.References: #874
1.6.5
1.6.5
Released: May 27, 2021
bug
-
[bug] [autogenerate] Fixed issue where dialect-specific keyword arguments within the
DropIndex
operation directive would not render in the
autogenerated Python code. As support was improved for adding dialect
specific arguments to directives as part of #803, in particular
arguments such as "postgresql_concurrently" which apply to the actual
create/drop of the index, support was needed for these to render even in a
drop index operation. Pull request courtesy Jet Zhou.References: #849
1.6.4
1.6.3
1.6.3
Released: May 21, 2021
bug
-
[bug] [autogenerate] [regression] Fixed 1.6-series regression where
UniqueConstraint
and to a lesser
extentIndex
objects would be doubled up in the generated model when
theunique=True
/index=True
flags were used.References: #844
-
[bug] [autogenerate] Fixed a bug where paths defined in post-write hook options
would be wrongly escaped in non posix environment (Windows).References: #839
-
[bug] [regression] [versioning] Fixed regression where a revision file that contained its own down revision
as a dependency would cause an endless loop in the traversal logic.References: #843
1.6.2
1.6.1
1.6.1
Released: May 6, 2021
bug
-
[bug] [regression] [versioning] Fixed regression in new revisioning traversal where "alembic downgrade
base" would fail if the database itself were clean and unversioned;
additionally repairs the case where downgrade would fail if attempting
to downgrade to the current head that is already present.References: #838
1.6.0
1.6.0
Released: May 3, 2021
feature
-
[feature] [autogenerate] Fix the documentation regarding the default command-line argument position of
the revision script filename within the post-write hook arguments. Implement a
REVISION_SCRIPT_FILENAME
token, enabling the position to be changed. Switch
fromstr.split()
toshlex.split()
for more robust command-line argument
parsing.References: #819
-
[feature] Implement a
.cwd
(current working directory) suboption for post-write hooks
(of typeconsole_scripts
). This is useful for tools like pre-commit, which
rely on the working directory to locate the necessary config files. Add
pre-commit as an example to the documentation. Minor change: rename some variables
from ticket #819 to improve readability.References: #822
bug
-
[bug] [autogenerate] Refactored the implementation of
MigrateOperation
constructs such
asCreateIndexOp
,CreateTableOp
, etc. so that they no
longer rely upon maintaining a persistent version of each schema object
internally; instead, the state variables of each operation object will be
used to produce the corresponding construct when the operation is invoked.
The rationale is so that environments which make use of
operation-manipulation schemes such as those those discussed in
autogen_rewriter
are better supported, allowing end-user code to
manipulate the public attributes of these objects which will then be
expressed in the final output, an example is
some_create_index_op.kw["postgresql_concurrently"] = True
.Previously, these objects when generated from autogenerate would typically
hold onto the original, reflected element internally without honoring the
other state variables of each construct, preventing the public API from
working.References: #803
-
[bug] [environment] Fixed regression caused by the SQLAlchemy 1.4/2.0 compatibility switch
where calling.rollback()
or.commit()
explicitly within the
context.begin_transaction()
context manager would cause it to fail when
the block ended, as it did not expect that the transaction was manually
closed.References: #829
-
[bug] [autogenerate] Improved the rendering of
op.add_column()
operations when adding
multiple columns to an existing table, so that the order of these
statements matches the order in which the columns were declared in the
application's table metadata. Previously the added columns were being
sorted alphabetically.References: #827
-
[bug] [versioning] The algorithm used for calculating downgrades/upgrades/iterating
revisions has been rewritten, to resolve ongoing issues of branches
not being handled consistently particularly within downgrade operations,
as well as for overall clarity and maintainability. This change includes
that a deprecation warning is emitted if an ambiguous command such
as "downgrade -1" when multiple heads are present is given.In particular, the change implements a long-requested use case of allowing
downgrades of a single branch to a branchpoint.Huge thanks to Simon Bowly for their impressive efforts in successfully
tackling this very difficult problem. -
[bug] [batch] Added missing
batch_op.create_table_comment()
,
batch_op.drop_table_comment()
directives to batch ops.References: #799
1.5.8
1.5.7
1.5.7
Released: March 11, 2021
bug
-
[bug] [autogenerate] Adjusted the recently added
EnvironmentContext.configure.include_name
hook to accommodate
for additional object types such as "views" that don't have a parent table,
to support third party recipes and extensions. Pull request courtesy Oliver
Rice.References: #813
1.5.6
1.5.6
Released: March 5, 2021
bug
-
[bug] [mssql] [operations] Fixed bug where the "existing_type" parameter, which the MSSQL dialect
requires in order to change the nullability of a column in the absence of
also changing the column type, would cause an ALTER COLUMN operation to
incorrectly render a second ALTER statement without the nullability if a
new type were also present, as the MSSQL-specific contract did not
anticipate all three of "nullability", "type_" and "existing_type" being
sent at the same time.References: #812
misc
- [template] Add async template to Alembic to bootstrap environments that use
async DBAPI. Updated the cookbook to include a migration guide
on how to adapt an existing enviroment for use with DBAPI drivers.