NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI · #154 most downloaded on PyPI
A database migration tool for SQLAlchemy.
Last release 22 days ago
11 Sep 2026
Release timing varies
gaps range from 2 weeks to 4 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
2 versions withdrawn
withdrawn after publishing
15 years old
148 releases · first in 2011
[bug] [environment] Fixed regression caused by SQLAlchemy 1.4 where the "alembic current" command would fail due to changes in the URL object.
Released: March 23, 2021
[bug] [environment] Fixed regression caused by SQLAlchemy 1.4 where the "alembic current"
command would fail due to changes in the URL object.
References: #816
[bug] [autogenerate] Adjusted the recently added EnvironmentContext.configure.include_name hook to accommodate for additional object types such as "vi
Released: March 11, 2021
[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
One column per quarter.
[bug] [mssql] [operations] Fixed bug where the "existing_type" parameter, which the MSSQL dialect requires in order to change the nullability of a col
Released: March 5, 2021
[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
[bug] Adjusted the use of SQLAlchemy's ".copy()" internals to use "._copy()" for version 1.4.0, as this method is being renamed.
Released: February 20, 2021
[bug] Adjusted the use of SQLAlchemy's ".copy()" internals to use "._copy()" for version 1.4.0, as this method is being renamed.
[bug] [environment] 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. To enable for existing installations, add the option to the
alembic.ini file as follows:
prepend_sys_path = .References: #797
Released: February 20, 2021
[bug] ¶ Adjusted the use of SQLAlchemy’s “.copy()” internals to use “._copy()” for version 1.4.0, as this method is being renamed.
[bug] [environment] ¶ 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. To enable for existing installations, add the option to the alembic.ini file as follows:
See also
Installation - updated documentation reflecting that local installation of the project is not necessary if running the Alembic cli from the local path.
References: #797
[bug] [versioning] Fixed bug in versioning model where a downgrade across a revision with a dependency on another branch, yet an ancestor is also depe
Released: February 3, 2021
[bug] [versioning] Fixed bug in versioning model where a downgrade across a revision with a dependency on another branch, yet an ancestor is also dependent on that branch, would produce an erroneous state in the alembic_version table, making upgrades impossible without manually repairing the table.
References: #789
[bug] [autogenerate] Changed the default ordering of "CREATE" and "DROP" statements indexes and unique constraints within the autogenerate process, so
Released: January 29, 2021
[bug] [autogenerate] Changed the default ordering of "CREATE" and "DROP" statements indexes and
unique constraints within the autogenerate process, so that for example in
an upgrade() operation, a particular index or constraint that is to be
replaced such as for a casing convention change will not produce any naming
conflicts. For foreign key constraint objects, this is already how
constraints are ordered, and for table objects, users would normally want
to use Operations.rename_table() in any case.
References: #786
[bug] [autogenerate] [mssql] Fixed assorted autogenerate issues with SQL Server:
- ignore default reflected identity on primary_key columns
- improve server default comparison
References: #787
[bug] [autogenerate] [mysql] Fixed issue where autogenerate rendering of op.alter_column() would
fail to include MySQL existing_nullable=False if the column were part
of a primary key constraint within the table metadata.
References: #788
[bug] [regression] [versioning] Fixed regression where new "loop detection" feature introduced in #757 produced false positives for revision names tha
Released: January 20, 2021
[bug] [regression] [versioning] Fixed regression where new "loop detection" feature introduced in #757 produced false positives for revision names that have overlapping substrings between revision number and down revision and/or dependency, if the downrev/dependency were not in sequence form.
References: #784
[bug] [environment] Fixed regression where Alembic would fail to create a transaction properly
if the sqlalchemy.engine.Connection were a so-called "branched"
connection, that is, one where the .connect() method had been called to
create a "sub" connection.
References: #782
[bug] [commands] [installation] Fixed installation issue where the "templates" directory was not being installed, preventing commands like "list_templ
Released: January 19, 2021
[bug] [commands] [installation] Fixed installation issue where the "templates" directory was not being installed, preventing commands like "list_templates" and "init" from working.
References: #780
[removed] [autogenerate] The long deprecated EnvironmentContext.configure.include_symbol hook is removed. The EnvironmentContext.configure.include_obj…
Released: January 18, 2021
[changed] [environment] To accommodate SQLAlchemy 1.4 and 2.0, the migration model now no longer
assumes that the SQLAlchemy Connection will autocommit an individual
operation. This essentially means that for databases that use
non-transactional DDL (pysqlite current driver behavior, MySQL), there is
still a BEGIN/COMMIT block that will surround each individual migration.
Databases that support transactional DDL should continue to have the
same flow, either per migration or per-entire run, depending on the
value of the Environment.configure.transaction_per_migration
flag.
[changed] [environment] A CommandError is raised if a sqlalchemy.engine.Engine is
passed to the MigrationContext.configure() method instead of a
sqlalchemy.engine.Connection object. Previously, this would be a
warning only.
[changed] Alembic 1.5.0 now supports Python 2.7 and Python 3.6 and above, as well as SQLAlchemy 1.3.0 and above. Support is removed for Python 3 versions prior to 3.6 and SQLAlchemy versions prior to the 1.3 series.
References: #748
[feature] [autogenerate] Added new hook EnvironmentContext.configure.include_name,
which complements the
EnvironmentContext.configure.include_object hook by providing
a means of preventing objects of a certain name from being autogenerated
before the SQLAlchemy reflection process takes place, and notably
includes explicit support for passing each schema name when
EnvironmentContext.configure.include_schemas is set to True.
This is most important especially for enviroments that make use of
EnvironmentContext.configure.include_schemas where schemas are
actually databases (e.g. MySQL) in order to prevent reflection sweeps of
the entire server.
References: #650
[feature] [versioning] The revision tree is now checked for cycles and loops between revision
files when the revision environment is loaded up. Scenarios such as a
revision pointing to itself, or a revision that can reach itself via a
loop, are handled and will raise the CycleDetected exception when
the environment is loaded (expressed from the Alembic commandline as a
failure message and nonzero return code). Previously, these situations were
silently ignored up front, and the behavior of revision traversal would
either be silently incorrect, or would produce errors such as
RangeNotAncestorError. Pull request courtesy Koichiro Den.
References: #757
[bug] [operations] Modified the add_column() operation such that the Column object in
use is shallow copied to a new instance if that Column is already
attached to a table() or Table. This accommodates for the change
made in SQLAlchemy issue #5618 which prohibits a Column from being
associated with multiple table() objects. This resumes support for
using a Column inside of an Alembic operation that already refers to a
parent table() or Table as well as allows operation objects just
autogenerated to work.
References: #753
[bug] [autogenerate] Added rendering for the Table.prefixes element to autogenerate so that
the rendered Python code includes these directives. Pull request courtesy
Rodrigo Ce Moretto.
References: #721
[bug] [batch] Added missing "create comment" feature for columns that are altered in batch migrations.
References: #761
[bug] [batch] Made an adjustment to the PostgreSQL dialect to allow it to work more effectively in batch mode, where a datatype like Boolean or non-native Enum that may have embedded rules to generate CHECK constraints will be more correctly handled in that these constraints usually will not have been generated on the PostgreSQL backend; previously it would inadvertently assume they existed unconditionally in a special PG-only "drop constraint" step.
References: #773
[usecase] [operations] Added support for rendering of "identity" elements on
Column objects, supported in SQLAlchemy via
the Identity element introduced in version 1.4.
Adding columns with identity is supported on PostgreSQL, MSSQL and Oracle. Changing the identity options or removing it is supported only on PostgreSQL and Oracle.
References: #730
[usecase] [commands] Add __main__.py file to alembic package to support invocation
with python -m alembic.
[removed] [autogenerate] The long deprecated
EnvironmentContext.configure.include_symbol hook is removed.
The EnvironmentContext.configure.include_object
and EnvironmentContext.configure.include_name
hooks both achieve the goals of this hook.
[removed] [commands] Removed deprecated --head_only option to the alembic current
command
[removed] [operations] Removed legacy parameter names from operations, these have been emitting warnings since version 0.8. In the case that legacy version files have not yet been updated, these can be modified directly in order to maintain compatibility:
- `Operations.drop_constraint()` - "type" (use "type_") and "name"
(use "constraint_name")
- `Operations.create_primary_key()` - "cols" (use "columns") and
"name" (use "constraint_name")
- `Operations.create_unique_constraint()` - "name" (use
"constraint_name"), "source" (use "table_name") and "local_cols" (use
"columns")
- `Operations.batch_create_unique_constraint()` - "name" (use
"constraint_name")
- `Operations.create_foreign_key()` - "name" (use "constraint_name"),
"source" (use "source_table"), "referent" (use "referent_table")
- `Operations.batch_create_foreign_key()` - "name" (use
"constraint_name"), "referent" (use "referent_table")
- `Operations.create_check_constraint()` - "name" (use
"constraint_name"), "source" (use "table_name")
- `Operations.batch_create_check_constraint()` - "name" (use
"constraint_name")
- `Operations.create_index()` - "name" (use "index_name")
- `Operations.drop_index()` - "name" (use "index_name"), "tablename"
(use "table_name")
- `Operations.batch_drop_index()` - "name" (use "index_name"),
- `Operations.create_table()` - "name" (use "table_name")
- `Operations.drop_table()` - "name" (use "table_name")
- `Operations.alter_column()` - "name" (use "new_column_name")
[bug] [batch] [sqlite] Added support to drop named CHECK constraints that are specified as part of a column, rather than table wide. Previously, only
Released: September 11, 2020
[bug] [batch] [sqlite] Added support to drop named CHECK constraints that are specified as part of a column, rather than table wide. Previously, only constraints associated with the table were considered.
References: #711
[bug] [mysql] [ops] Fixed issue where the MySQL dialect would not correctly render the server default of a column in an alter operation, if the operation were programmatically generated from an autogenerate pass as it would not accommodate for the full structure of the DefaultClause construct.
References: #736
[bug] [batch] [sqlite] Fixed issue where the CAST applied to a JSON column when copying a SQLite table during batch mode would cause the data to be lost, as SQLite's CAST with JSON appears to convert the data to the value "0". The CAST is now skipped in a dialect-specific manner, including for JSON columns on SQLite. Pull request courtesy Sebastián Ramírez.
References: #697
[bug] [commands] The alembic current command no longer creates an alembic_version
table in the database if one does not exist already, returning no version
as the current version. This allows checking for migrations in parallel
without introducing race conditions. Pull request courtesy Nikolay
Edigaryev.
References: #694
[bug] [batch] Fixed issue where columns in a foreign-key referenced table would be
replaced with null-type columns during a batch operation; while this did
not generally have any side effects, it could theoretically impact a batch
operation that also targets that table directly and also would interfere
with future changes to the .append_column() method to disallow implicit
replacement of columns.
[bug] [mssql] Fixed issue where the mssql_drop_foreign_key=True flag on
op.drop_column would lead to incorrect syntax error due to a typo in the
SQL emitted, same typo was present in the test as well so it was not
detected. Pull request courtesy Oleg Shigorin.
References: #716
[bug] [tests] Fixed an issue that prevented the test suite from running with the recently released py.test 5.4.0.
Released: March 19, 2020
[bug] [tests] Fixed an issue that prevented the test suite from running with the recently released py.test 5.4.0.
References: #668
[bug] [autogenerate] [mysql] Fixed more false-positive failures produced by the new "compare type" logic first added in #605, particularly impacting MySQL string types regarding flags such as "charset" and "collation".
References: #617
[bug] [op directives] [oracle] Fixed issue in Oracle backend where a table RENAME with a schema-qualified name would include the schema in the "to" portion, which is rejected by Oracle.
References: #670
[usecase] [autogenerate] Adjusted autogen comparison to accommodate for backends that support
computed column reflection, dependent on SQLAlchemy version 1.3.16 or
higher. This emits a warning if the SQL expression inside of a
Computed value changes between the metadata and the database, as
these expressions can't be changed without dropping and recreating the
column.
References: #669
[bug] [autogenerate] Fixed regression caused by the new "type comparison" logic introduced in 1.4 as part of #605 where comparisons of MySQL "unsigned
Released: March 1, 2020
[bug] [autogenerate] Fixed regression caused by the new "type comparison" logic introduced in 1.4 as part of #605 where comparisons of MySQL "unsigned integer" datatypes would produce false positives, as the regular expression logic was not correctly parsing the "unsigned" token when MySQL's default display width would be returned by the database. Pull request courtesy Paul Becotte.
References: #661
[bug] [environment] Error message for "path doesn't exist" when loading up script environment now displays the absolute path. Pull request courtesy Rowan Hart.
References: #663
[bug] [autogenerate] Fixed regression in 1.4.0 due to #647 where unique constraint comparison with mixed case constraint names while not using a naming convention would produce false positives during autogenerate.
References: #654
[bug] [environment] The check for matched rowcount when the alembic_version table is updated or deleted from is now conditional based on whether or not the dialect supports the concept of "rowcount" for UPDATE or DELETE rows matched. Some third party dialects do not support this concept. Pull request courtesy Ke Zhu.
[bug] [operations] Fixed long-standing bug where an inline column CHECK constraint would not
be rendered within an "ADD COLUMN" operation. The DDL compiler is now
consulted for inline constraints within the Operations.add_column()
method as is done for regular CREATE TABLE operations.
References: #655
[change] The internal inspection routines no longer use SQLAlchemy's Inspector.from_engine() method, which is expected to be deprecated in 1.4. The in…
Released: February 4, 2020
[feature] [batch] Added new parameters BatchOperations.add_column.insert_before,
BatchOperations.add_column.insert_after which provide for
establishing the specific position in which a new column should be placed.
Also added Operations.batch_alter_table.partial_reordering
which allows the complete set of columns to be reordered when the new table
is created. Both operations apply only to when batch mode is recreating
the whole table using recreate="always". Thanks to Marcin Szymanski
for assistance with the implementation.
References: #640
[bug] [autogenerate] Adjusted the unique constraint comparison logic in a similar manner as that of #421 did for indexes in order to take into account SQLAlchemy's own truncation of long constraint names when a naming convention is in use. Without this step, a name that is truncated by SQLAlchemy based on a unique constraint naming convention or hardcoded name will not compare properly.
References: #647
[bug] [autogenerate] A major rework of the "type comparison" logic is in place which changes the entire approach by which column datatypes are compared. Types are now compared based on the DDL string generated by the metadata type vs. the datatype reflected from the database. This means we compare types based on what would actually render and additionally if elements of the types change like string length, those changes are detected as well. False positives like those generated between SQLAlchemy Boolean and MySQL TINYINT should also be resolved. Thanks very much to Paul Becotte for lots of hard work and patience on this one.
References: #605
[usecase] [environment] Moved the use of the __file__ attribute at the base of the Alembic
package into the one place that it is specifically needed, which is when
the config attempts to locate the template directory. This helps to allow
Alembic to be fully importable in environments that are using Python
memory-only import schemes. Pull request courtesy layday.
References: #648
Inspector.from_engine() method, which is expected to be deprecated in
1.4. The inspect() function is now used.Released: February 4, 2020
[feature] [batch] ¶ Added new parameters BatchOperations.add_column.insert_before , BatchOperations.add_column.insert_after which provide for establishing the specific position in which a new column should be placed. Also added Operations.batch_alter_table.partial_reordering which allows the complete set of columns to be reordered when the new table is created. Both operations apply only to when batch mode is recreating the whole table using recreate="always" . Thanks to Marcin Szymanski for assistance with the implementation.
References: #640
[usecase] [environment] ¶ Moved the use of the file attribute at the base of the Alembic package into the one place that it is specifically needed, which is when the config attempts to locate the template directory. This helps to allow Alembic to be fully importable in environments that are using Python memory-only import schemes. Pull request courtesy layday.
References: #648
[bug] [autogenerate] ¶ Adjusted the unique constraint comparison logic in a similar manner as that of #421 did for indexes in order to take into account SQLAlchemy’s own truncation of long constraint names when a naming convention is in use. Without this step, a name that is truncated by SQLAlchemy based on a unique constraint naming convention or hardcoded name will not compare properly.
References: #647
[bug] [autogenerate] ¶ A major rework of the “type comparison” logic is in place which changes the entire approach by which column datatypes are compared. Types are now compared based on the DDL string generated by the metadata type vs. the datatype reflected from the database. This means we compare types based on what would actually render and additionally if elements of the types change like string length, those changes are detected as well. False positives like those generated between SQLAlchemy Boolean and MySQL TINYINT should also be resolved. Thanks very much to Paul Becotte for lots of hard work and patience on this one.
Note
updated - this change also removes support for the compare_against_backend SQLAlchemy type hook.
See also
What does Autogenerate Detect (and what does it not detect?) - updated comments on type comparison
References: #605
[change] ¶ The internal inspection routines no longer use SQLAlchemy’s Inspector.from_engine() method, which is expected to be deprecated in 1.4. The inspect() function is now used.
[bug] [postgresql] Fixed issue where COMMENT directives for PostgreSQL failed to correctly include an explicit schema name, as well as correct quoting
Released: January 22, 2020
[bug] [postgresql] Fixed issue where COMMENT directives for PostgreSQL failed to correctly include an explicit schema name, as well as correct quoting rules for schema, table, and column names. Pull request courtesy Matthew Sills.
References: #637
[usecase] [operations] Added support for rendering of "computed" elements on Column
objects, supported in SQLAlchemy via the new Computed element
introduced in version 1.3.11. Pull request courtesy Federico Caselli.
Note that there is currently no support for ALTER COLUMN to add, remove, or
modify the "GENERATED ALWAYS AS" element from a column; at least for
PostgreSQL, it does not seem to be supported by the database. Additionally,
SQLAlchemy does not currently reliably reflect the "GENERATED ALWAYS AS"
phrase from an existing column, so there is also no autogenerate support
for addition or removal of the Computed element to or from an
existing column, there is only support for adding new columns that include
the Computed element. In the case that the Computed
element is removed from the Column object in the table metadata,
PostgreSQL and Oracle currently reflect the "GENERATED ALWAYS AS"
expression as the "server default" which will produce an op that tries to
drop the element as a default.
References: #624
[bug] [api] [autogenerate] Fixed regression introduced by #579 where server default rendering functions began to require a dialect implementation, how
Released: December 16, 2019
[bug] [api] [autogenerate] Fixed regression introduced by #579 where server default rendering
functions began to require a dialect implementation, however the
render_python_code() convenience function did not include one, thus
causing the function to fail when used in a server default context. The
function now accepts a migration context argument and also creates one
against the default dialect if one is not provided.
References: #635
[bug] [mssql] Fixed bug in MSSQL dialect where the drop constraint execution steps used to remove server default or implicit foreign key constraint fa
no release date
[bug] [mssql] Fixed bug in MSSQL dialect where the drop constraint execution steps used to remove server default or implicit foreign key constraint failed to take into account the schema name of the target table.
References: #621
[feature] [command] Added support for ALEMBIC_CONFIG environment variable, refers to the location of the alembic configuration script in lieu of using
Released: October 31, 2019
[feature] [command] Added support for ALEMBIC_CONFIG environment variable, refers to the location of the alembic configuration script in lieu of using the -c command line option.
References: #608
[bug] [autogenerate] Fixed bug in new Variant autogenerate where the order of the arguments to Variant were mistakenly reversed.
References: #131
[bug] [command] Reverted the name change of the "revisions" argument to command.stamp() to "revision" as apparently applications are calling upon this
Released: September 24, 2019
[bug] [command] Reverted the name change of the "revisions" argument to
command.stamp() to "revision" as apparently applications are
calling upon this argument as a keyword name. Pull request courtesy
Thomas Bechtold. Special translations are also added to the command
line interface so that it is still known as "revisions" in the CLI.
References: #601
[bug] [tests] Removed the "test requirements" from "setup.py test", as this command now only emits a removal error in any case and these requirements are unused.
References: #592
[command] [feature] Added new --purge flag to the alembic stamp command, which will unconditionally erase the version table before stamping anything.
Released: September 20, 2019
[command] [feature] Added new --purge flag to the alembic stamp command, which will
unconditionally erase the version table before stamping anything. This is
useful for development where non-existent version identifiers might be left
within the table. Additionally, alembic.stamp now supports a list of
revision identifiers, which are intended to allow setting up muliple heads
at once. Overall handling of version identifiers within the
alembic.stamp command has been improved with many new tests and
use cases added.
References: #473
[autogenerate] [bug] Improved the Python rendering of a series of migration operations such that
a single "pass" is rendered for a UpgradeOps or
DowngradeOps based on if no lines of Python code actually
rendered under the operation, rather than whether or not sub-directives
exist. Removed extra "pass" lines that would generate from the
ModifyTableOps directive so that these aren't duplicated under
operation rewriting scenarios.
References: #550
[feature] [runtime] Added new feature MigrationContext.autocommit_block(), a special
directive which will provide for a non-transactional block inside of a
migration script. The feature requres that: the database driver
(e.g. DBAPI) supports the AUTOCOMMIT isolation mode. The directive
also necessarily needs to COMMIT the existing transaction in progress
in order to enter autocommit mode.
References: #123
[change: py3k] Python 3.4 support is dropped, as the upstream tooling (pip, mysqlclient) etc are already dropping support for Python 3.4, which itself is no longer maintained.
[autogenerate] [usecase] Added autogenerate support for Column objects that have
dialect-specific **kwargs, support first added in SQLAlchemy 1.3.
This includes SQLite "on conflict" as well as options used by some
third party dialects.
References: #518
[autogenerate] [usecase] Added rendering for SQLAlchemy Variant datatypes, which render as the
base type plus one or more .with_variant() method calls.
References: #131
[commands] [feature] Added "post write hooks" to revision generation. These allow custom logic
to run after a revision Python script is generated, typically for the
purpose of running code formatters such as "Black" or "autopep8", but may
be used for any arbitrary post-render hook as well, including custom Python
functions or scripts. The hooks are enabled by providing a
[post_write_hooks] section in the alembic.ini file. A single hook
is provided which runs an arbitrary Python executable on the newly
generated revision script, which can be configured to run code formatters
such as Black; full examples are included in the documentation.
References: #307
[commands] [usecase] Made the command interface revision lookup behavior more strict in that an Alembic revision number is only resolved based on a partial match rules if it has at least four characters, to prevent simple typographical issues from inadvertently running migrations.
References: #534
[environment] [feature] Added new flag --package to alembic init. For environments where
the Alembic migration files and such are within the package tree and
importable as modules, this flag can be specified which will add the
additional __init__.py files in the version location and the
environment location.
References: #463
[autogenerate] [bug] Fixed bug where rendering of comment text for table-level comments within
Operations.create_table_comment() and
Operations.drop_table_comment() was not properly quote-escaped
within rendered Python code for autogenerate.
References: #549
[autogenerate] [bug] Modified the logic of the Rewriter object such that it keeps a
memoization of which directives it has processed, so that it can ensure it
processes a particular directive only once, and additionally fixed
Rewriter so that it functions correctly for multiple-pass
autogenerate schemes, such as the one illustrated in the "multidb"
template. By tracking which directives have been processed, a
multiple-pass scheme which calls upon the Rewriter multiple times
for the same structure as elements are added can work without running
duplicate operations on the same elements more than once.
References: #505
Released: September 20, 2019
[feature] [command] ¶ Added new --purge flag to the alembic stamp command, which will unconditionally erase the version table before stamping anything. This is useful for development where non-existent version identifiers might be left within the table. Additionally, alembic.stamp now supports a list of revision identifiers, which are intended to allow setting up multiple heads at once. Overall handling of version identifiers within the alembic.stamp command has been improved with many new tests and use cases added.
References: #473
[feature] [runtime] ¶ Added new feature MigrationContext.autocommit_block() , a special directive which will provide for a non-transactional block inside of a migration script. The feature requires that: the database driver (e.g. DBAPI) supports the AUTOCOMMIT isolation mode. The directive also necessarily needs to COMMIT the existing transaction in progress in order to enter autocommit mode.
See also
MigrationContext.autocommit_block()
References: #123
[feature] [commands] ¶ Added “post write hooks” to revision generation. These allow custom logic to run after a revision Python script is generated, typically for the purpose of running code formatters such as “Black” or “autopep8”, but may be used for any arbitrary post-render hook as well, including custom Python functions or scripts. The hooks are enabled by providing a [post_write_hooks] section in the alembic.ini file. A single hook is provided which runs an arbitrary Python executable on the newly generated revision script, which can be configured to run code formatters such as Black; full examples are included in the documentation.
See also
Applying Post Processing and Python Code Formatters to Generated Revisions
References: #307
[feature] [environment] ¶ Added new flag --package to alembic init . For environments where the Alembic migration files and such are within the package tree and importable as modules, this flag can be specified which will add the additional init.py files in the version location and the environment location.
References: #463
[usecase] [autogenerate] ¶ Added autogenerate support for Column objects that have dialect-specific **kwargs , support first added in SQLAlchemy 1.3. This includes SQLite “on conflict” as well as options used by some third party dialects.
References: #518
[usecase] [autogenerate] ¶ Added rendering for SQLAlchemy Variant datatypes, which render as the base type plus one or more .with_variant() method calls.
References: #131
[usecase] [commands] ¶
Made the command interface revision lookup behavior more strict in that an Alembic revision number is only resolved based on a partial match rules if it has at least four characters, to prevent simple typographical issues from inadvertently running migrations.
References: #534
[bug] [autogenerate] ¶ Improved the Python rendering of a series of migration operations such that a single “pass” is rendered for a UpgradeOps or DowngradeOps based on if no lines of Python code actually rendered under the operation, rather than whether or not sub-directives exist. Removed extra “pass” lines that would generate from the ModifyTableOps directive so that these aren’t duplicated under operation rewriting scenarios.
References: #550
[bug] [autogenerate] ¶ Fixed bug where rendering of comment text for table-level comments within Operations.create_table_comment() and Operations.drop_table_comment() was not properly quote-escaped within rendered Python code for autogenerate.
References: #549
[bug] [autogenerate] ¶ Modified the logic of the Rewriter object such that it keeps a memoization of which directives it has processed, so that it can ensure it processes a particular directive only once, and additionally fixed Rewriter so that it functions correctly for multiple-pass autogenerate schemes, such as the one illustrated in the “multidb” template. By tracking which directives have been processed, a multiple-pass scheme which calls upon the Rewriter multiple times for the same structure as elements are added can work without running duplicate operations on the same elements more than once.
References: #505
[change: py3k] ¶ Python 3.4 support is dropped, as the upstream tooling (pip, mysqlclient) etc are already dropping support for Python 3.4, which itself is no longer maintained.
[bug] [py3k] Fixed use of the deprecated "imp" module, which is used to detect pep3147 availability as well as to locate .pyc files, which started emi…
Released: August 26, 2019
[change] Alembic 1.1 bumps the minimum version of SQLAlchemy to 1.1. As was the case before, Python requirements remain at Python 2.7, or in the 3.x series Python 3.4.
[change] [internals] The test suite for Alembic now makes use of SQLAlchemy's testing framework directly. Previously, Alembic had its own version of this framework that was mostly copied from that of SQLAlchemy to enable testing with older SQLAlchemy versions. The majority of this code is now removed so that both projects can leverage improvements from a common testing framework.
[bug] [commands] Fixed bug where the double-percent logic applied to some dialects such as
psycopg2 would be rendered in --sql mode, by allowing dialect options
to be passed through to the dialect used to generate SQL and then providing
paramstyle="named" so that percent signs need not be doubled. For
users having this issue, existing env.py scripts need to add
dialect_opts={"paramstyle": "named"} to their offline
context.configure(). See the alembic/templates/generic/env.py template
for an example.
References: #562
[bug] [py3k] Fixed use of the deprecated "imp" module, which is used to detect pep3147 availability as well as to locate .pyc files, which started emitting deprecation warnings during the test suite. The warnings were not being emitted earlier during the test suite, the change is possibly due to changes in py.test itself but this is not clear. The check for pep3147 is set to True for any Python version 3.5 or greater now and importlib is used when available. Note that some dependencies such as distutils may still be emitting this warning. Tests are adjusted to accommodate for dependencies that emit the warning as well.
[bug] [mysql] Fixed issue where emitting a change of column name for MySQL did not preserve the column comment, even if it were specified as existing_comment.
References: #594
[bug] [setup] Removed the "python setup.py test" feature in favor of a straight run of "tox". Per Pypa / pytest developers, "setup.py" commands are in general headed towards deprecation in favor of tox. The tox.ini script has been updated such that running "tox" with no arguments will perform a single run of the test suite against the default installed Python interpreter.
References: #592
[commands] [usecase] The "alembic init" command will now proceed if the target directory exists as long as it's still empty. Previously, it would not proceed if the directory existed. The new behavior is modeled from what git does, to accommodate for container or other deployments where an Alembic target directory may need to be already mounted instead of being created with alembic init. Pull request courtesy Aviskar KC.
References: #571
Originally, Python was emitting deprecation warnings for this function in Python 3.8 alphas. While this change was reverted, it was observed that Pyth…
Released: June 25, 2019
[autogenerate] [batch] [bug] [sqlite] SQLite server default reflection will ensure parenthesis are surrounding a
column default expression that is detected as being a non-constant
expression, such as a datetime() default, to accommodate for the
requirement that SQL expressions have to be parenthesized when being sent
as DDL. Parenthesis are not added to constant expressions to allow for
maximum cross-compatibility with other dialects and existing test suites
(such as Alembic's), which necessarily entails scanning the expression to
eliminate for constant numeric and string values. The logic is added to the
two "reflection->DDL round trip" paths which are currently autogenerate and
batch migration. Within autogenerate, the logic is on the rendering side,
whereas in batch the logic is installed as a column reflection hook.
References: #579
[autogenerate] [bug] [sqlite] Improved SQLite server default comparison to accommodate for a text()
construct that added parenthesis directly vs. a construct that relied
upon the SQLAlchemy SQLite dialect to render the parenthesis, as well
as improved support for various forms of constant expressions such as
values that are quoted vs. non-quoted.
References: #579
[autogenerate] [bug] Fixed bug where the "literal_binds" flag was not being set when autogenerate would create a server default value, meaning server default comparisons would fail for functions that contained literal values.
[bug] [mysql] Added support for MySQL "DROP CHECK", which is added as of MySQL 8.0.16, separate from MariaDB's "DROP CONSTRAINT" for CHECK constraints. The MySQL Alembic implementation now checks for "MariaDB" in server_version_info to decide which one to use.
References: #554
[bug] [mysql] [operations] Fixed issue where MySQL databases need to use CHANGE COLUMN when altering a server default of CURRENT_TIMESTAMP, NOW() and probably other functions that are only usable with DATETIME/TIMESTAMP columns. While MariaDB supports both CHANGE and ALTER COLUMN in this case, MySQL databases only support CHANGE. So the new logic is that if the server default change is against a DateTime-oriented column, the CHANGE format is used unconditionally, as in the vast majority of cases the server default is to be CURRENT_TIMESTAMP which may also be potentially bundled with an "ON UPDATE CURRENT_TIMESTAMP" directive, which SQLAlchemy does not currently support as a distinct field. The fix addiionally improves the server default comparison logic when the "ON UPDATE" clause is present and there are parenthesis to be adjusted for as is the case on some MariaDB versions.
References: #564
[bug] [environment] Warnings emitted by Alembic now include a default stack level of 2, and in some cases it's set to 3, in order to help warnings indicate more closely where they are originating from. Pull request courtesy Ash Berlin-Taylor.
[bug] [py3k] Replaced the Python compatbility routines for getargspec() with a fully
vendored version based on getfullargspec() from Python 3.3.
Originally, Python was emitting deprecation warnings for this function in
Python 3.8 alphas. While this change was reverted, it was observed that
Python 3 implementations for getfullargspec() are an order of magnitude
slower as of the 3.4 series where it was rewritten against Signature.
While Python plans to improve upon this situation, SQLAlchemy projects for
now are using a simple replacement to avoid any future issues.
References: #563
[bug] [commands] Fixed bug introduced in release 0.9.0 where the helptext for commands inadvertently got expanded to include function docstrings from
Released: April 28, 2019
[bug] [commands] Fixed bug introduced in release 0.9.0 where the helptext for commands inadvertently got expanded to include function docstrings from the command.py module. The logic has been adjusted to only refer to the first line(s) preceding the first line break within each docstring, as was the original intent.
References: #552
[bug] [mysql] [operations] Added an assertion in RevisionMap.get_revisions() and other methods
which ensures revision numbers are passed as strings or collections of
strings. Driver issues particularly on MySQL may inadvertently be passing
bytes here which leads to failures later on.
References: #551
[autogenerate] [bug] [mysql] Fixed bug when using the
EnvironmentContext.configure.compare_server_default flag set
to True where a server default that is introduced in the table metadata
on an Integer column, where there is no existing server default in the
database, would raise a TypeError.
References: #553
[bug] [operations] Simplified the internal scheme used to generate the alembic.op namespace to no longer attempt to generate full method signatures (e
Released: April 15, 2019
[bug] [operations] Simplified the internal scheme used to generate the alembic.op namespace
to no longer attempt to generate full method signatures (e.g. rather than
generic *args, **kw) as this was not working in most cases anyway, while
in rare circumstances it would in fact sporadically have access to the real
argument names and then fail when generating the function due to missing
symbols in the argument signature.
References: #548
[bug] [operations] Removed use of deprecated force parameter for SQLAlchemy quoting functions as this parameter will be removed in a future release. P…
Released: March 4, 2019
[bug] [operations] Removed use of deprecated force parameter for SQLAlchemy quoting
functions as this parameter will be removed in a future release.
Pull request courtesy Parth Shandilya(ParthS007).
References: #528
[autogenerate] [bug] [postgresql] [py3k] Fixed issue where server default comparison on the PostgreSQL dialect would fail for a blank string on Python 3.7 only, due to a change in regular expression behavior in Python 3.7.
References: #541
[autogenerate] [bug] Fixed issue in new comment support where autogenerated Python code for comments wasn't using repr() thus causing issues with quot
Released: January 25, 2019
[autogenerate] [bug] Fixed issue in new comment support where autogenerated Python code
for comments wasn't using repr() thus causing issues with
quoting. Pull request courtesy Damien Garaud.
References: #529
Released: January 25, 2019
[bug] [autogenerate] ¶ Fixed issue in new comment support where autogenerated Python code for comments wasn’t using repr() thus causing issues with quoting. Pull request courtesy Damien Garaud.
References: #529
[feature] [operations] Added Table and Column level comments for supported backends. New methods Operations.create_table_comment() and Operations.drop
Released: January 13, 2019
[feature] [operations] Added Table and Column level comments for supported backends.
New methods Operations.create_table_comment() and
Operations.drop_table_comment() are added. A new arguments
Operations.alter_column.comment and
Operations.alter_column.existing_comment are added to
Operations.alter_column(). Autogenerate support is also added
to ensure comment add/drops from tables and columns are generated as well
as that Operations.create_table(), Operations.add_column()
both include the comment field from the source Table
or Column object.
References: #422
[bug] [py3k] Resolved remaining Python 3 deprecation warnings, covering the use of inspect.formatargspec() with a vendored version copied from the Pyt…
Released: November 27, 2018
[bug] [py3k] Resolved remaining Python 3 deprecation warnings, covering the use of inspect.formatargspec() with a vendored version copied from the Python standard library, importing collections.abc above Python 3.3 when testing against abstract base classes, fixed one occurrence of log.warn(), as well as a few invalid escape sequences.
References: #507
[change] Code hosting has been moved to GitHub, at https://github.com/sqlalchemy/alembic. Additionally, the main Alembic website documentation URL is
Released: November 27, 2018
[change] ¶ Code hosting has been moved to GitHub, at sqlalchemy/alembic . Additionally, the main Alembic website documentation URL is now https://alembic.sqlalchemy.org .
[bug] [mssql] Fixed regression caused by #513, where the logic to consume mssql_include was not correctly interpreting the case where the flag was not
[autogenerate] [bug] The system=True flag on Column, used primarily in conjunction with the Postgresql "xmin" column, now renders within the autogener
Released: October 31, 2018
[autogenerate] [bug] The system=True flag on Column, used primarily in conjunction
with the Postgresql "xmin" column, now renders within the autogenerate
render process, allowing the column to be excluded from DDL. Additionally,
adding a system=True column to a model will produce no autogenerate diff as
this column is implicitly present in the database.
References: #515
[bug] [mssql] Fixed issue where usage of the SQL Server mssql_include option within a
Operations.create_index() would raise a KeyError, as the additional
column(s) need to be added to the table object used by the construct
internally.
References: #513
[bug] [commands] Fixed an issue where revision descriptions were essentially being formatted twice. Any revision description that contained characters
Released: October 17, 2018
[bug] [commands] Fixed an issue where revision descriptions were essentially being formatted twice. Any revision description that contained characters like %, writing output to stdout will fail because the call to config.print_stdout attempted to format any additional args passed to the function. This fix now only applies string formatting if any args are provided along with the output text.
References: #497
[autogenerate] [bug] Fixed issue where removed method union_update() was used when a
customized MigrationScript instance included entries in the
.imports data member, raising an AttributeError.
References: #512
[feature] [general] For Alembic 1.0, Python 2.6 / 3.3 support is being dropped, allowing a fixed setup.py to be built as well as universal wheels. Pul
Released: July 13, 2018
[feature] [general] For Alembic 1.0, Python 2.6 / 3.3 support is being dropped, allowing a fixed setup.py to be built as well as universal wheels. Pull request courtesy Hugo.
References: #491
[feature] [general] With the 1.0 release, Alembic's minimum SQLAlchemy support version moves to 0.9.0, previously 0.7.9.
[batch] [bug] Fixed issue in batch where dropping a primary key column, then adding it back under the same name but without the primary_key flag, would not remove it from the existing PrimaryKeyConstraint. If a new PrimaryKeyConstraint is added, it is used as-is, as was the case before.
References: #502
[autogenerate] [bug] The "op.drop_constraint()" directive will now render using repr() for the schema name, in the same way that "schema" renders for
Released: June 29, 2018
[autogenerate] [bug] The "op.drop_constraint()" directive will now render using repr() for
the schema name, in the same way that "schema" renders for all the other op
directives. Pull request courtesy Denis Kataev.
[autogenerate] [bug] Added basic capabilities for external dialects to support rendering of "nested" types, like arrays, in a manner similar to that of the Postgresql dialect.
References: #494
[autogenerate] [bug] Fixed issue where "autoincrement=True" would not render for a column that specified it, since as of SQLAlchemy 1.1 this is no longer the default value for "autoincrement". Note the behavior only takes effect against the SQLAlchemy 1.1.0 and higher; for pre-1.1 SQLAlchemy, "autoincrement=True" does not render as was the case before. Pull request courtesy Elad Almos.
Released: June 29, 2018
[bug] [autogenerate] ¶ The “op.drop_constraint()” directive will now render using repr() for the schema name, in the same way that “schema” renders for all the other op directives. Pull request courtesy Denis Kataev.
[bug] [autogenerate] ¶ Added basic capabilities for external dialects to support rendering of “nested” types, like arrays, in a manner similar to that of the Postgresql dialect.
References: #494
[bug] [autogenerate] ¶ Fixed issue where “autoincrement=True” would not render for a column that specified it, since as of SQLAlchemy 1.1 this is no longer the default value for “autoincrement”. Note the behavior only takes effect against the SQLAlchemy 1.1.0 and higher; for pre-1.1 SQLAlchemy, “autoincrement=True” does not render as was the case before. Pull request courtesy Elad Almos.
[commands] [feature] Added new flag --indicate-current to the alembic history command. When listing versions, it will include the token "(current)" to
Released: March 22, 2018
[commands] [feature] Added new flag --indicate-current to the alembic history command.
When listing versions, it will include the token "(current)" to indicate
the given version is a current head in the target database. Pull request
courtesy Kazutaka Mise.
References: #481
[autogenerate] [bug] [mysql] The fix for #455 in version 0.9.6 involving MySQL server default comparison was entirely non functional, as the test itself was also broken and didn't reveal that it wasn't working. The regular expression to compare server default values like CURRENT_TIMESTAMP to current_timestamp() is repaired.
References: #455
[autogenerate] [bug] [mysql] Fixed bug where MySQL server default comparisons were basically not working at all due to incorrect regexp added in #455. Also accommodates for MariaDB 10.2 quoting differences in reporting integer based server defaults.
References: #483
[bug] [mysql] [operations] Fixed bug in op.drop_constraint() for MySQL where
quoting rules would not be applied to the constraint name.
References: #487
[bug] [runtime] Fixed bug where the Script.as_revision_number() method did not accommodate for the 'heads' identifier, which in turn caused the Enviro
Released: February 16, 2018
[bug] [runtime] Fixed bug where the Script.as_revision_number() method
did not accommodate for the 'heads' identifier, which in turn
caused the EnvironmentContext.get_head_revisions()
and EnvironmentContext.get_revision_argument() methods
to be not usable when multiple heads were present.
The :meth:.EnvironmentContext.get_head_revisions method returns
a tuple in all cases as documented.
References: #482
[autogenerate] [bug] [postgresql] Fixed bug where autogenerate of ExcludeConstraint
would render a raw quoted name for a Column that has case-sensitive
characters, which when invoked as an inline member of the Table
would produce a stack trace that the quoted name is not found.
An incoming Column object is now rendered as sa.column('name').
References: #478
[autogenerate] [bug] Fixed bug where the indexes would not be included in a migration that was dropping the owning table. The fix now will also emit DROP INDEX for the indexes ahead of time, but more importantly will include CREATE INDEX in the downgrade migration.
References: #468
[bug] [postgresql] Fixed the autogenerate of the module prefix when rendering the text_type parameter of postgresql.HSTORE, in much the same way that we do for ARRAY's type and JSON's text_type.
References: #480
[bug] [mysql] Added support for DROP CONSTRAINT to the MySQL Alembic dialect to support MariaDB 10.2 which now has real CHECK constraints. Note this change does not add autogenerate support, only support for op.drop_constraint() to work.
References: #479
[autogenerate] [bug] Fixed regression caused by #421 which would cause case-sensitive quoting rules to interfere with the comparison logic for index n
Released: January 16, 2018
[autogenerate] [bug] Fixed regression caused by #421 which would cause case-sensitive quoting rules to interfere with the comparison logic for index names, thus causing indexes to show as added for indexes that have case-sensitive names. Works with SQLAlchemy 0.9 and later series.
References: #472
[autogenerate] [bug] [postgresql] Fixed bug where autogenerate would produce a DROP statement for the index implicitly created by a Postgresql EXCLUDE constraint, rather than skipping it as is the case for indexes implicitly generated by unique constraints. Makes use of SQLAlchemy 1.0.x's improved "duplicates index" metadata and requires at least SQLAlchemy version 1.0.x to function correctly.
References: #461
[bug] [commands] Fixed a few Python3.6 deprecation warnings by replacing StopIteration with return, as well as using getfullargspec() instead of getar…
Released: October 13, 2017
[bug] [commands] Fixed a few Python3.6 deprecation warnings by replacing StopIteration
with return, as well as using getfullargspec() instead of
getargspec() under Python 3.
References: #458
[bug] [commands] An addition to #441 fixed in 0.9.5, we forgot to also filter
for the + sign in migration names which also breaks due to the relative
migrations feature.
References: #441
[autogenerate] [bug] Fixed bug expanding upon the fix for
#85 which adds the correct module import to the
"inner" type for an ARRAY type, the fix now accommodates for the
generic sqlalchemy.types.ARRAY type added in SQLAlchemy 1.1,
rendering the inner type correctly regardless of whether or not the
Postgresql dialect is present.
References: #442
[bug] [mysql] Fixed bug where server default comparison of CURRENT_TIMESTAMP would fail on MariaDB 10.2 due to a change in how the function is represented by the database during reflection.
References: #455
[autogenerate] [bug] Fixed bug where comparison of Numeric types would produce
a difference if the Python-side Numeric inadvertently specified
a non-None "scale" with a "precision" of None, even though this Numeric
type will pass over the "scale" argument when rendering. Pull request
courtesy Ivan Mmelnychuk.
[commands] [feature] The alembic history command will now make use of the revision
environment env.py unconditionally if the revision_environment
configuration flag is set to True. Previously, the environment would
only be invoked if the history specification were against a database-stored
revision token.
References: #447
[batch] [bug] The name of the temporary table in batch mode is now generated off of the original table name itself, to avoid conflicts for the unusual case of multiple batch operations running against the same database schema at the same time.
References: #457
[autogenerate] [bug] A ForeignKeyConstraint can now render correctly if the
link_to_name flag is set, as it will not attempt to resolve the name
from a "key" in this case. Additionally, the constraint will render
as-is even if the remote column name isn't present on the referenced
remote table.
References: #456
[bug] [py3k] [runtime] Reworked "sourceless" system to be fully capable of handling any
combination of: Python2/3x, pep3149 or not, PYTHONOPTIMIZE or not,
for locating and loading both env.py files as well as versioning files.
This includes: locating files inside of __pycache__ as well as listing
out version files that might be only in versions/__pycache__, deduplicating
version files that may be in versions/__pycache__ and versions/
at the same time, correctly looking for .pyc or .pyo files based on
if pep488 is present or not. The latest Python3x deprecation warnings
involving importlib are also corrected.
References: #449
[bug] [commands] A CommandError is raised if the "--rev-id" passed to the revision() command contains dashes or at-signs, as this interferes with the
Released: August 9, 2017
[bug] [commands] A CommandError is raised if the "--rev-id" passed to the
revision() command contains dashes or at-signs, as this interferes
with the command notation used to locate revisions.
References: #441
[bug] [postgresql] Added support for the dialect-specific keyword arguments
to Operations.drop_index(). This includes support for
postgresql_concurrently and others.
References: #424
[bug] [commands] Fixed bug in timezone feature introduced in #425 when the creation date in a revision file is calculated, to accommodate for timezone names that contain mixed-case characters in their name as opposed to all uppercase. Pull request courtesy Nils Philippsen.
[bug] [runtime] Added an additional attribute to the new EnvironmentContext.configure.on_version_apply API, MigrationInfo.up_revision_ids, to accommod
Released: July 31, 2017
EnvironmentContext.configure.on_version_apply API,
MigrationInfo.up_revision_ids, to accommodate for the uncommon
case of the alembic stamp command being used to move from multiple
branches down to a common branchpoint; there will be multiple
"up" revisions in this one case.[feature] [runtime] Added a new callback hook EnvironmentContext.configure.on_version_apply, which allows user-defined code to be invoked each time an
Released: July 6, 2017
[feature] [runtime] Added a new callback hook
EnvironmentContext.configure.on_version_apply,
which allows user-defined code to be invoked each time an individual
upgrade, downgrade, or stamp operation proceeds against a database.
Pull request courtesy John Passaro.
[autogenerate] [bug] Fixed bug where autogen comparison of a Variant datatype
would not compare to the dialect level type for the "default"
implementation of the Variant, returning the type as changed
between database and table metadata.
References: #433
[bug] [tests] Fixed unit tests to run correctly under the SQLAlchemy 1.0.x series prior to version 1.0.10 where a particular bug involving Postgresql exclude constraints was fixed.
References: #431
[bug] [mssql] Repaired Operations.rename_table() for SQL Server when the target table is in a remote schema, the schema name is omitted from the "new
Released: May 18, 2017
[bug] [mssql] Repaired Operations.rename_table() for SQL Server when the
target table is in a remote schema, the schema name is omitted from
the "new name" argument.
References: #429
[commands] [feature] Added a new configuration option timezone, a string timezone name
that will be applied to the create date timestamp rendered
inside the revision file as made availble to the file_template used
to generate the revision filename. Note this change adds the
python-dateutil package as a dependency.
References: #425
[autogenerate] [bug] The autogenerate compare scheme now takes into account the name truncation
rules applied by SQLAlchemy's DDL compiler to the names of the
Index object, when these names are dynamically truncated
due to a too-long identifier name. As the identifier truncation is
deterministic, applying the same rule to the metadata name allows
correct comparison to the database-derived name.
References: #421
[bug environment] A warning is emitted when an object that's not a
~sqlalchemy.engine.Connection is passed to
EnvironmentContext.configure(). For the case of a
~sqlalchemy.engine.Engine passed, the check for "in transaction"
introduced in version 0.9.0 has been relaxed to work in the case of an
attribute error, as some users appear to be passing an
~sqlalchemy.engine.Engine and not a
~sqlalchemy.engine.Connection.
References: #419
Released: May 18, 2017
[feature] [commands] ¶ Added a new configuration option timezone , a string timezone name that will be applied to the create date timestamp rendered inside the revision file as made available to the file_template used to generate the revision filename. Note this change adds the python-dateutil package as a dependency.
References: #425
[bug] [mssql] ¶ Repaired Operations.rename_table() for SQL Server when the target table is in a remote schema, the schema name is omitted from the “new name” argument.
References: #429
[bug] [autogenerate] ¶ The autogenerate compare scheme now takes into account the name truncation rules applied by SQLAlchemy’s DDL compiler to the names of the Index object, when these names are dynamically truncated due to a too-long identifier name. As the identifier truncation is deterministic, applying the same rule to the metadata name allows correct comparison to the database-derived name.
References: #421
[bug environment] ¶ A warning is emitted when an object that’s not a Connection is passed to EnvironmentContext.configure() . For the case of a Engine passed, the check for “in transaction” introduced in version 0.9.0 has been relaxed to work in the case of an attribute error, as some users appear to be passing an Engine and not a Connection .
References: #419
[bug] [commands] An adjustment to the bug fix for #369 to accommodate for env.py scripts that use an enclosing transaction distinct from the one that
Released: March 1, 2017
[autogenerate] [feature] The EnvironmentContext.configure.target_metadata parameter may now be optionally specified as a sequence of MetaData objects
Released: February 28, 2017
[autogenerate] [feature] The EnvironmentContext.configure.target_metadata parameter
may now be optionally specified as a sequence of MetaData
objects instead of a single MetaData object. The
autogenerate process will process the sequence of MetaData
objects in order.
References: #38
[bug] [commands] A CommandError is now raised when a migration file opens
a database transaction and does not close/commit/rollback, when
the backend database or environment options also specify transactional_ddl
is False. When transactional_ddl is not in use, Alembic doesn't
close any transaction so a transaction opened by a migration file
will cause the following migrations to fail to apply.
References: #369
[autogenerate] [bug] [mysql] The autoincrement=True flag is now rendered within the
Operations.alter_column() operation if the source column indicates
that this flag should be set to True. The behavior is sensitive to
the SQLAlchemy version in place, as the "auto" default option is new
in SQLAlchemy 1.1. When the source column indicates autoincrement
as True or "auto", the flag will render as True if the original column
contextually indicates that it should have "autoincrement" keywords,
and when the source column explcitly sets it to False, this is also
rendered. The behavior is intended to preserve the AUTO_INCREMENT flag
on MySQL as the column is fully recreated on this backend. Note that this
flag does not support alteration of a column's "autoincrement" status,
as this is not portable across backends.
References: #413
[bug] [postgresql] Fixed bug where Postgresql JSON/JSONB types rendered on SQLAlchemy
1.1 would render the "astext_type" argument which defaults to
the Text() type without the module prefix, similarly to the
issue with ARRAY fixed in #85.
References: #411
[bug] [postgresql] Fixed bug where Postgresql ARRAY type would not render the import prefix for the inner type; additionally, user-defined renderers take place for the inner type as well as the outer type. Pull request courtesy Paul Brackin.
References: #85
[autogenerate] [feature] Added a keyword argument process_revision_directives to the
command.revision() API call. This function acts in the
same role as the environment-level
EnvironmentContext.configure.process_revision_directives,
and allows API use of the
command to drop in an ad-hoc directive process function. This
function can be used among other things to place a complete
MigrationScript structure in place.
[feature] [postgresql] Added support for Postgresql EXCLUDE constraints, including the
operation directive Operations.create_exclude_constraints()
as well as autogenerate render support for the ExcludeConstraint
object as present in a Table. Autogenerate detection for an EXCLUDE
constraint added or removed to/from an existing table is not
implemented as the SQLAlchemy Postgresql dialect does not yet support
reflection of EXCLUDE constraints.
Additionally, unknown constraint types now warn when encountered within an autogenerate action rather than raise.
References: #412
[bug] [operations] Fixed bug in ops.create_foreign_key() where the internal table
representation would not be created properly if the foriegn key referred
to a table in a different schema of the same name. Pull request
courtesy Konstantin Lebedev.
[bug] [versioning] The alembic_version table, when initially created, now establishes a primary key constraint on the "version_num" column, to suit da
Released: January 17, 2017
[bug] [versioning] The alembic_version table, when initially created, now establishes a
primary key constraint on the "version_num" column, to suit database
engines that don't support tables without primary keys. This behavior
can be controlled using the parameter
EnvironmentContext.configure.version_table_pk. Note that
this change only applies to the initial creation of the alembic_version
table; it does not impact any existing alembic_version table already
present.
References: #406
[batch] [bug] Fixed bug where doing batch_op.drop_constraint() against the
primary key constraint would fail to remove the "primary_key" flag
from the column, resulting in the constraint being recreated.
References: #402
[autogenerate] [bug] [oracle] Adjusted the logic originally added for #276 that detects MySQL unique constraints which are actually unique indexes to be generalized for any dialect that has this behavior, for SQLAlchemy version 1.0 and greater. This is to allow for upcoming SQLAlchemy support for unique constraint reflection for Oracle, which also has no dedicated concept of "unique constraint" and instead establishes a unique index.
[bug] [versioning] Added a file ignore for Python files of the form .#<name>.py,
which are generated by the Emacs editor. Pull request courtesy
Markus Mattes.
References: #356
[autogenerate] [bug] Adjustment to the "please adjust!" comment in the script.py.mako template so that the generated comment starts with a single poun
Released: November 28, 2016
[autogenerate] [bug] Adjustment to the "please adjust!" comment in the script.py.mako template so that the generated comment starts with a single pound sign, appeasing flake8.
References: #393
[batch] [bug] Batch mode will not use CAST() to copy data if type_ is given, however the basic type affinity matches that of the existing type. This to avoid SQLite's CAST of TIMESTAMP which results in truncation of the data, in those cases where the user needs to add redundant type_ for other reasons.
References: #391
[autogenerate] [bug] Continued pep8 improvements by adding appropriate whitespace in the base template for generated migrations. Pull request courtesy Markus Mattes.
References: #393
[bug] [revisioning] Added an additional check when reading in revision files to detect if the same file is being read twice; this can occur if the same directory or a symlink equivalent is present more than once in version_locations. A warning is now emitted and the file is skipped. Pull request courtesy Jiri Kuncar.
[autogenerate] [bug] Fixed bug where usage of a custom TypeDecorator which returns a
per-dialect type via TypeDecorator.load_dialect_impl() that differs
significantly from the default "impl" for the type decorator would fail
to compare correctly during autogenerate.
References: #395
[autogenerate] [bug] [postgresql] Fixed bug in Postgresql "functional index skip" behavior where a functional index that ended in ASC/DESC wouldn't be detected as something we can't compare in autogenerate, leading to duplicate definitions in autogenerated files.
References: #392
[bug] [versioning] Fixed bug where the "base" specifier, as in "base:head", could not
be used explicitly when --sql mode was present.
[autogenerate] The imports in the default script.py.mako are now at the top so that flake8 editors don't complain by default. PR courtesy Guilherme Ma
Released: September 12, 2016
[autogenerate] The imports in the default script.py.mako are now at the top so that flake8 editors don't complain by default. PR courtesy Guilherme Mansur.
[feature] [operations] [postgresql] Added support for the USING clause to the ALTER COLUMN operation
for Postgresql. Support is via the
op.alter_column.postgresql_using
parameter. Pull request courtesy Frazer McLean.
References: #292
[autogenerate] [feature] Autogenerate with type comparison enabled will pick up on the timezone setting changing between DateTime types. Pull request courtesy David Szotten.
Released: September 12, 2016
[feature] [operations] [postgresql] ¶ Added support for the USING clause to the ALTER COLUMN operation for Postgresql. Support is via the op.alter_column.postgresql_using parameter. Pull request courtesy Frazer McLean.
References: #292
[feature] [autogenerate] ¶ Autogenerate with type comparison enabled will pick up on the timezone setting changing between DateTime types. Pull request courtesy David Szotten.
[autogenerate] ¶ The imports in the default script.py.mako are now at the top so that flake8 editors don’t complain by default. PR courtesy Guilherme Mansur.
[bug] [versioning] Fixed bug where upgrading to the head of a branch which is already present would fail, only if that head were also the dependency o
Released: July 26, 2016
[bug] [versioning] Fixed bug where upgrading to the head of a branch which is already present would fail, only if that head were also the dependency of a different branch that is also upgraded, as the revision system would see this as trying to go in the wrong direction. The check here has been refined to distinguish between same-branch revisions out of order vs. movement along sibling branches.
References: #336
[bug] [versioning] Adjusted the version traversal on downgrade such that we can downgrade to a version that is a dependency for a version in a different branch, without needing to remove that dependent version as well. Previously, the target version would be seen as a "merge point" for it's normal up-revision as well as the dependency. This integrates with the changes for #377 and #378 to improve treatment of branches with dependencies overall.
References: #379
[bug] [versioning] Fixed bug where a downgrade to a version that is also a dependency to a different branch would fail, as the system attempted to treat this as an "unmerge" of a merge point, when in fact it doesn't have the other side of the merge point available for update.
References: #377
[bug] [versioning] Fixed bug where the "alembic current" command wouldn't show a revision as a current head if it were also a dependency of a version in a different branch that's also applied. Extra logic is added to extract "implied" versions of different branches from the top-level versions listed in the alembic_version table.
References: #378
[bug] [versioning] Fixed bug where a repr() or str() of a Script object would fail if the script had multiple dependencies.
[autogenerate] [bug] Fixed bug in autogen where if the DB connection sends the default schema as "None", this "None" would be removed from the list of schemas to check if include_schemas were set. This could possibly impact using include_schemas with SQLite.
[batch] [bug] Small adjustment made to the batch handling for reflected CHECK constraints to accommodate for SQLAlchemy 1.1 now reflecting these. Batch mode still does not support CHECK constraints from the reflected table as these can't be easily differentiated from the ones created by types such as Boolean.
[bug] [commands] Errors which occur within the Mako render step are now intercepted and raised as CommandErrors like other failure cases; the Mako exc
Released: April 14, 2016
[bug] [commands] Errors which occur within the Mako render step are now intercepted and raised as CommandErrors like other failure cases; the Mako exception itself is written using template-line formatting to a temporary file which is named in the exception message.
References: #367
[bug] [postgresql] Added a fix to Postgresql server default comparison which first checks if the text of the default is identical to the original, before attempting to actually run the default. This accomodates for default-generation functions that generate a new value each time such as a uuid function.
References: #365
[batch] [bug] Fixed bug introduced by the fix for #338 in version 0.8.4 where a server default could no longer be dropped in batch mode. Pull request courtesy Martin Domke.
References: #361
[batch] [bug] [mssql] Fixed bug where SQL Server arguments for drop_column() would not be propagated when running under a batch block. Pull request courtesy Michal Petrucha.
[autogenerate] [bug] Fixed bug where the columns rendered in a PrimaryKeyConstraint in autogenerate would inappropriately render the "key" of the colu
Released: March 9, 2016
[autogenerate] [bug] Fixed bug where the columns rendered in a PrimaryKeyConstraint
in autogenerate would inappropriately render the "key" of the
column, not the name. Pull request courtesy Jesse Dhillon.
References: #335
[batch] [bug] Repaired batch migration support for "schema" types which generate
constraints, in particular the Boolean datatype which generates
a CHECK constraint. Previously, an alter column operation with this
type would fail to correctly accommodate for the CHECK constraint
on change both from and to this type. In the former case the operation
would fail entirely, in the latter, the CHECK constraint would
not get generated. Both of these issues are repaired.
References: #354
[bug] [mysql] Changing a schema type such as Boolean to a non-schema type would
emit a drop constraint operation which emits NotImplementedError for
the MySQL dialect. This drop constraint operation is now skipped when
the constraint originates from a schema type.
References: #355
[feature] [versioning] A major improvement to the hash id generation function, which for some reason used an awkward arithmetic formula against uuid4(
Released: December 15, 2015
[feature] [versioning] A major improvement to the hash id generation function, which for some reason used an awkward arithmetic formula against uuid4() that produced values that tended to start with the digits 1-4. Replaced with a simple substring approach which provides an even distribution. Pull request courtesy Antti Haapala.
[autogenerate] [feature] Added an autogenerate renderer for the ExecuteSQLOp operation
object; only renders if given a plain SQL string, otherwise raises
NotImplementedError. Can be of help with custom autogenerate
sequences that includes straight SQL execution. Pull request courtesy
Jacob Magnusson.
[batch] [bug] Batch mode generates a FOREIGN KEY constraint that is self-referential
using the ultimate table name, rather than _alembic_batch_temp.
When the table is renamed from _alembic_batch_temp back to the
original name, the FK now points to the right name. This
will not work if referential integrity is being enforced (eg. SQLite
"PRAGMA FOREIGN_KEYS=ON") since the original table is dropped and
the new table then renamed to that name, however this is now consistent
with how foreign key constraints on other tables already operate
with batch mode; these don't support batch mode if referential integrity
is enabled in any case.
References: #345
[autogenerate] [bug] Added a type-level comparator that distinguishes Integer,
BigInteger, and SmallInteger types and
dialect-specific types; these all have "Integer" affinity so previously
all compared as the same.
References: #341
[batch] [bug] Fixed bug where the server_default parameter of alter_column()
would not function correctly in batch mode.
References: #338
[autogenerate] [bug] Adjusted the rendering for index expressions such that a Column
object present in the source Index will not be rendered
as table-qualified; e.g. the column name will be rendered alone.
Table-qualified names here were failing on systems such as Postgresql.
References: #337
[autogenerate] [bug] Fixed an 0.8 regression whereby the "imports" dictionary member of the autogen context was removed; this collection is documented
Released: October 16, 2015
[autogenerate] [bug] Fixed an 0.8 regression whereby the "imports" dictionary member of
the autogen context was removed; this collection is documented in the
"render custom type" documentation as a place to add new imports.
The member is now known as
AutogenContext.imports and the documentation is repaired.
References: #332
[batch] [bug] Fixed bug in batch mode where a table that had pre-existing indexes would create the same index on the new table with the same name, which on SQLite produces a naming conflict as index names are in a global namespace on that backend. Batch mode now defers the production of both existing and new indexes until after the entire table transfer operation is complete, which also means those indexes no longer take effect during the INSERT from SELECT section as well; the indexes are applied in a single step afterwards.
References: #333
[bug] [tests] Added "pytest-xdist" as a tox dependency, so that the -n flag in the test command works if this is not already installed. Pull request courtesy Julien Danjou.
[autogenerate] [bug] [postgresql] Fixed issue in PG server default comparison where model-side defaults
configured with Python unicode literals would leak the "u" character
from a repr() into the SQL used for comparison, creating an invalid
SQL expression, as the server-side comparison feature in PG currently
repurposes the autogenerate Python rendering feature to get a quoted
version of a plain string default.
References: #324
[autogenerate] [bug] Added workaround in new foreign key option detection feature for MySQL's consideration of the "RESTRICT" option being the default
Released: August 25, 2015
[autogenerate] [bug] Added workaround in new foreign key option detection feature for MySQL's consideration of the "RESTRICT" option being the default, for which no value is reported from the database; the MySQL impl now corrects for when the model reports RESTRICT but the database reports nothing. A similar rule is in the default FK comparison to accommodate for the default "NO ACTION" setting being present in the model but not necessarily reported by the database, or vice versa.
References: #321
[autogenerate] [feature] A custom EnvironmentContext.configure.process_revision_directives hook can now generate op directives within the UpgradeOps a
Released: August 22, 2015
[autogenerate] [feature] A custom EnvironmentContext.configure.process_revision_directives
hook can now generate op directives within the UpgradeOps
and DowngradeOps containers that will be generated as Python
code even when the --autogenerate flag is False; provided that
revision_environment=True, the full render operation will be run
even in "offline" mode.
[autogenerate] [bug] Repaired the render operation for the ops.AlterColumnOp object
to succeed when the "existing_type" field was not present.
[autogenerate] [bug] Fixed a regression 0.8 whereby the "multidb" environment template
failed to produce independent migration script segments for the
output template. This was due to the reorganization of the script
rendering system for 0.8. To accommodate this change, the
MigrationScript structure will in the case of multiple
calls to MigrationContext.run_migrations() produce lists
for the MigrationScript.upgrade_ops and
MigrationScript.downgrade_ops attributes; each UpgradeOps
and DowngradeOps instance keeps track of its own
upgrade_token and downgrade_token, and each are rendered
individually.
References: #318
[autogenerate] [feature] Implemented support for autogenerate detection of changes in the
ondelete, onupdate, initially and deferrable
attributes of ForeignKeyConstraint objects on
SQLAlchemy backends that support these on reflection
(as of SQLAlchemy 1.0.8 currently Postgresql for all four,
MySQL for ondelete and onupdate only). A constraint object
that modifies these values will be reported as a "diff" and come out
as a drop/create of the constraint with the modified values.
The fields are ignored for backends which don't reflect these
attributes (as of SQLA 1.0.8 this includes SQLite, Oracle, SQL Server,
others).
References: #317
Released: August 22, 2015
[feature] [autogenerate] ¶ A custom EnvironmentContext.configure.process_revision_directives hook can now generate op directives within the UpgradeOps and DowngradeOps containers that will be generated as Python code even when the --autogenerate flag is False; provided that revision_environment=True , the full render operation will be run even in “offline” mode.
[feature] [autogenerate] ¶ Implemented support for autogenerate detection of changes in the ondelete , onupdate , initially and deferrable attributes of ForeignKeyConstraint objects on SQLAlchemy backends that support these on reflection (as of SQLAlchemy 1.0.8 currently Postgresql for all four, MySQL for ondelete and onupdate only). A constraint object that modifies these values will be reported as a “diff” and come out as a drop/create of the constraint with the modified values. The fields are ignored for backends which don’t reflect these attributes (as of SQLA 1.0.8 this includes SQLite, Oracle, SQL Server, others).
References: #317
[bug] [autogenerate] ¶ Repaired the render operation for the ops.AlterColumnOp object to succeed when the “existing_type” field was not present.
[bug] [autogenerate] ¶ Fixed a regression 0.8 whereby the “multidb” environment template failed to produce independent migration script segments for the output template. This was due to the reorganization of the script rendering system for 0.8. To accommodate this change, the MigrationScript structure will in the case of multiple calls to MigrationContext.run_migrations() produce lists for the MigrationScript.upgrade_ops and MigrationScript.downgrade_ops attributes; each UpgradeOps and DowngradeOps instance keeps track of its own upgrade_token and downgrade_token , and each are rendered individually.
See also
Revision Generation with Multiple Engines / run_migrations() calls - additional detail on the workings of the EnvironmentContext.configure.process_revision_directives parameter when multiple calls to MigrationContext.run_migrations() are made.
References: #318
[batch] [bug] Fixed bug in batch mode where the batch_op.create_foreign_key() directive would be incorrectly rendered with the source table and schema
Released: August 12, 2015
[batch] [bug] Fixed bug in batch mode where the batch_op.create_foreign_key()
directive would be incorrectly rendered with the source table and
schema names in the argument list.
References: #315
[commands] [feature] Added new command alembic edit. This command takes the same
arguments as alembic show, however runs the target script
file within $EDITOR. Makes use of the python-editor library
in order to facilitate the handling of $EDITOR with reasonable
default behaviors across platforms. Pull request courtesy
Michel Albert.
[commands] [feature] Added new multiple-capable argument --depends-on to the
alembic revision command, allowing depends_on to be
established at the command line level rather than having to edit
the file after the fact. depends_on identifiers may also be
specified as branch names at the command line or directly within
the migration file. The values may be specified as partial
revision numbers from the command line which will be resolved to
full revision numbers in the output file.
References: #311
[change] [operations] A range of positional argument names have been changed to be
clearer and more consistent across methods within the
Operations namespace. The most prevalent form of name change
is that the descriptive names constraint_name and table_name
are now used where previously the name name would be used.
This is in support of the newly modularized and extensible system of
operation objects in alembic.operations.ops.
An argument translation layer is in place
across the alembic.op namespace that will ensure that named
argument calling styles that use the old names will continue to
function by transparently translating to the new names,
also emitting a warning. This, along with the fact that these
arguments are positional in any case and aren't normally
passed with an explicit name, should ensure that the
overwhelming majority of applications should be unaffected by this
change. The only applications that are impacted are those that:
- use the `Operations` object directly in some way, rather
than calling upon the `alembic.op` namespace, and
- invoke the methods on `Operations` using named keyword
arguments for positional arguments like `table_name`,
`constraint_name`, etc., which commonly were named `name`
as of 0.7.6.
- any application that is using named keyword arguments in place
of positional argument for the recently added
`BatchOperations` object may also be affected.
The naming changes are documented as "versionchanged" for 0.8.0:
- `BatchOperations.create_check_constraint()`
- `BatchOperations.create_foreign_key()`
- `BatchOperations.create_index()`
- `BatchOperations.create_unique_constraint()`
- `BatchOperations.drop_constraint()`
- `BatchOperations.drop_index()`
- `Operations.create_check_constraint()`
- `Operations.create_foreign_key()`
- `Operations.create_primary_key()`
- `Operations.create_index()`
- `Operations.create_table()`
- `Operations.create_unique_constraint()`
- `Operations.drop_constraint()`
- `Operations.drop_index()`
- `Operations.drop_table()`
[feature] [tests] The default test runner via "python setup.py test" is now py.test. nose still works via run_tests.py.
[feature] [operations] The internal system for Alembic operations has been reworked to now
build upon an extensible system of operation objects. New operations
can be added to the op. namespace, including that they are
available in custom autogenerate schemes.
References: #302
[autogenerate] [feature] The internal system for autogenerate been reworked to build upon
the extensible system of operation objects present in
#302. As part of this change, autogenerate now produces
a full object graph representing a list of migration scripts to
be written as well as operation objects that will render all the
Python code within them; a new hook
EnvironmentContext.configure.process_revision_directives
allows end-user code to fully customize what autogenerate will do,
including not just full manipulation of the Python steps to take
but also what file or files will be written and where. Additionally,
autogenerate is now extensible as far as database objects compared
and rendered into scripts; any new operation directive can also be
registered into a series of hooks that allow custom database/model
comparison functions to run as well as to render new operation
directives into autogenerate scripts.
[bug] [versioning] Fixed bug where in the erroneous case that alembic_version contains duplicate revisions, some commands would fail to process the version history correctly and end up with a KeyError. The fix allows the versioning logic to proceed, however a clear error is emitted later when attempting to update the alembic_version table.
References: #314
[bug] [versioning] Fixed critical issue where a complex series of branches/merges would bog down the iteration algorithm working over redundant nodes
Released: July 22, 2015
[bug] [versioning] Fixed critical issue where a complex series of branches/merges would bog down the iteration algorithm working over redundant nodes for millions of cycles. An internal adjustment has been made so that duplicate nodes are skipped within this iteration.
References: #310
[batch] [feature] Implemented support for BatchOperations.create_primary_key()
and BatchOperations.create_check_constraint(). Additionally,
table keyword arguments are copied from the original reflected table,
such as the "mysql_engine" keyword argument.
References: #305
[bug] [environment] The MigrationContext.stamp() method, added as part of the
versioning refactor in 0.7 as a more granular version of
command.stamp(), now includes the "create the alembic_version
table if not present" step in the same way as the command version,
which was previously omitted.
References: #300
[autogenerate] [bug] Fixed bug where foreign key options including "onupdate",
"ondelete" would not render within the op.create_foreign_key()
directive, even though they render within a full
ForeignKeyConstraint directive.
References: #298
[bug] [tests] Repaired warnings that occur when running unit tests against SQLAlchemy 1.0.5 or greater involving the "legacy_schema_aliasing" flag.
[feature] [versioning] Fixed bug where the case of multiple mergepoints that all have the identical set of ancestor revisions would fail to be upgrada
Released: May 5, 2015
[feature] [versioning] Fixed bug where the case of multiple mergepoints that all have the identical set of ancestor revisions would fail to be upgradable, producing an assertion failure. Merge points were previously assumed to always require at least an UPDATE in alembic_revision from one of the previous revs to the new one, however in this case, if one of the mergepoints has already been reached, the remaining mergepoints have no row to UPDATE therefore they must do an INSERT of their target version.
References: #297
[autogenerate] [feature] Added support for type comparison functions to be not just per
environment, but also present on the custom types themselves, by
supplying a method compare_against_backend.
Added a new documentation section compare_types describing
type comparison fully.
References: #296
[feature] [operations] Added a new option
EnvironmentContext.configure.literal_binds, which
will pass the literal_binds flag into the compilation of SQL
constructs when using "offline" mode. This has the effect that
SQL objects like inserts, updates, deletes as well as textual
statements sent using text() will be compiled such that the dialect
will attempt to render literal values "inline" automatically.
Only a subset of types is typically supported; the
Operations.inline_literal() construct remains as the construct
used to force a specific literal representation of a value.
The EnvironmentContext.configure.literal_binds flag
is added to the "offline" section of the env.py files generated
in new environments.
References: #255
[batch] [bug] Fully implemented the
~.Operations.batch_alter_table.copy_from parameter for
batch mode, which previously was not functioning. This allows
"batch mode" to be usable in conjunction with --sql.
References: #289
[batch] [bug] Repaired support for the BatchOperations.create_index()
directive, which was mis-named internally such that the operation
within a batch context could not proceed. The create index
operation will proceed as part of a larger "batch table recreate"
operation only if
~.Operations.batch_alter_table.recreate is set to
"always", or if the batch operation includes other instructions that
require a table recreate.
References: #287
Nothing published for this version
Nothing published for this version
[autogenerate] [bug] [postgresql] Repaired issue where a server default specified without text() that represented a numeric or floating point (e.g. wi
Released: January 12, 2015
[autogenerate] [bug] [postgresql] Repaired issue where a server default specified without text()
that represented a numeric or floating point (e.g. with decimal places)
value would fail in the Postgresql-specific check for "compare server
default"; as PG accepts the value with quotes in the table specification,
it's still valid. Pull request courtesy Dimitris Theodorou.
References: #241
[autogenerate] [bug] The rendering of a ~sqlalchemy.schema.ForeignKeyConstraint
will now ensure that the names of the source and target columns are
the database-side name of each column, and not the value of the
.key attribute as may be set only on the Python side.
This is because Alembic generates the DDL for constraints
as standalone objects without the need to actually refer to an in-Python
~sqlalchemy.schema.Table object, so there's no step that
would resolve these Python-only key names to database column names.
References: #259
[autogenerate] [bug] Fixed bug in foreign key autogenerate where if the in-Python table
used custom column keys (e.g. using the key='foo' kwarg to
Column), the comparison of existing foreign keys to those specified
in the metadata would fail, as the reflected table would not have
these keys available which to match up. Foreign key comparison for
autogenerate now ensures it's looking at the database-side names
of the columns in all cases; this matches the same functionality
within unique constraints and indexes.
References: #260
[autogenerate] [bug] Fixed issue in autogenerate type rendering where types that belong
to modules that have the name "sqlalchemy" in them would be mistaken
as being part of the sqlalchemy. namespace. Pull req courtesy
Bartosz Burclaf.
References: #261
[bug] [versioning] Fixed regression in new versioning system where upgrade / history operation would fail on AttributeError if no version files were p
Released: December 30, 2014
[bug] [versioning] Fixed regression in new versioning system where upgrade / history operation would fail on AttributeError if no version files were present at all.
References: #258
Your coding agent can read these notes before it upgrades. Set up the MCP server →