Mike Bayer [Fri, 21 Aug 2015 17:06:56 +0000 (13:06 -0400)]
- add a test and changelog notes for the fact that a non-autogenerate
run can render Python code in upgradeops/downgradeops via the
process_revision_directives hook.
Mike Bayer [Thu, 20 Aug 2015 22:51:08 +0000 (18:51 -0400)]
- 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
:class:`.MigrationScript` structure will in the case of multiple
calls to :meth:`.MigrationContext.run_migrations` produce lists
for the :attr:`.MigrationScript.upgrade_ops` and
:attr:`.MigrationScript.downgrade_ops` attributes; each :class:`.UpgradeOps`
and :class:`.DowngradeOps` instance keeps track of its own
``upgrade_token`` and ``downgrade_token``, and each are rendered
individually.
fixes #318
Mike Bayer [Wed, 19 Aug 2015 22:39:44 +0000 (18:39 -0400)]
- Implemented support for autogenerate detection of changes in the
``ondelete``, ``onupdate``, ``initially`` and ``deferrable``
attributes of :class:`.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). fixes #317
Mike Bayer [Wed, 12 Aug 2015 15:46:08 +0000 (11:46 -0400)]
- 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.
fixes #315
Mike Bayer [Sat, 8 Aug 2015 02:25:41 +0000 (22:25 -0400)]
- ensure that all ops have full backwards/forwards maintenance of
the original object passed in from autogenerate. In particular this
ensures that the diff structure from compare_metadata is fully backwards compatible
with no chance of synthesized objects.
Mike Bayer [Fri, 7 Aug 2015 21:58:12 +0000 (17:58 -0400)]
- add a helper object for autogen rewriting called Rewriter.
this provides for operation-specific handler functions.
docs are based on the example requested in references #313.
Mike Bayer [Mon, 3 Aug 2015 23:18:30 +0000 (19:18 -0400)]
- 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.
fixes #314
Mike Bayer [Thu, 30 Jul 2015 18:09:47 +0000 (14:09 -0400)]
- changelog for pullrequest bitbucket:46; "alembic edit" command
edits migration files using $EDITOR
- alter the edit command so that it accepts an argument in the same
way as ``alembic show``.
Mike Bayer [Tue, 28 Jul 2015 22:52:51 +0000 (18:52 -0400)]
- 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.
fixes #311
Mike Bayer [Wed, 22 Jul 2015 16:37:35 +0000 (12:37 -0400)]
- 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.
fixes #310
Mike Bayer [Fri, 17 Jul 2015 17:18:47 +0000 (13:18 -0400)]
- ensure DropIndex and other ops return the full object it received
from autogenerate; in the immediate sense this should help with
modelsmigrationsync tests
Mike Bayer [Thu, 16 Jul 2015 23:00:55 +0000 (19:00 -0400)]
- rework all of autogenerate to build directly on alembic.operations.ops
objects; the "diffs" is now a legacy system that is exported from
the ops. A new model of comparison/rendering/ upgrade/downgrade
composition that is cleaner and much more extensible is introduced.
- 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.
- write all new docs for the new system
fixes #306
Mike Bayer [Tue, 14 Jul 2015 16:42:19 +0000 (12:42 -0400)]
- move the "legacy names" system into where we create the module proxy.
This is so that we can do a total open ended "*args, **kw" style translation
for the vast majority of use cases that are using alembic.op, without impacting
docstrings for the Operations class.
There is a risk here of impacting an application that is using Operations
directly instantitaed while using old names. We may still have to accommodate
that somehow.
Mike Bayer [Fri, 3 Jul 2015 21:29:17 +0000 (17:29 -0400)]
- Implemented support for :meth:`.BatchOperations.create_primary_key`
and :meth:`.BatchOperations.create_check_constraint`.
fixes #305
- table keyword arguments are copied from the original reflected table,
such as the "mysql_engine" keyword argument.
Mike Bayer [Fri, 3 Jul 2015 17:10:41 +0000 (13:10 -0400)]
- squash merge of ticket_302 branch
- 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. fixes #302
- The internal system for autogenerate been reworked to build upon
the extensible system of operation objects present in #302.
A new customization hook process_revision_directives is added
to allow manipulation of the autogen stream. Fixes #301
Mike Bayer [Tue, 9 Jun 2015 15:40:34 +0000 (11:40 -0400)]
- The :meth:`.MigrationContext.stamp` method, added as part of the
versioning refactor in 0.7 as a more granular version of
:func:`.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.
fixes #300
Mike Bayer [Tue, 19 May 2015 00:21:49 +0000 (20:21 -0400)]
- 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.
fixes #298
Mike Bayer [Mon, 4 May 2015 00:17:19 +0000 (20:17 -0400)]
- 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.
fixes #297
Mike Bayer [Thu, 30 Apr 2015 15:33:58 +0000 (11:33 -0400)]
- 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 :ref:`compare_types` describing
type comparison fully.
fixes #296
Mike Bayer [Tue, 7 Apr 2015 16:36:51 +0000 (12:36 -0400)]
- Added a new option
:paramref:`.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
:meth:`.Operations.inline_literal` construct remains as the construct
used to force a specific literal representation of a value.
The :paramref:`.EnvironmentContext.configure.literal_binds` flag
is added to the "offline" section of the ``env.py`` files generated
in new environments.
fixes #255
- enhance the op_fixture as well as MigrationContext._stdout_connection()
so that it uses the real DefaultImpl
and MigrationContext fully in tests.
Mike Bayer [Fri, 27 Mar 2015 22:55:00 +0000 (18:55 -0400)]
- Fully implemented the
:paramref:`~.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``.
fixes #289
- sqlite dialect checks for "create_index" and "drop_index" as exceptions
for "recreate" in batch mode, the same way as "add_column", so that
unnecessary table recreates don't emit for index-only operations
Mike Bayer [Fri, 27 Mar 2015 19:15:55 +0000 (15:15 -0400)]
- Repaired support for the :meth:`.BatchOperations.create_index`
directive, which was mis-named internally such that the operation
within a batch context could not proceed.
fixes #287
Mike Bayer [Tue, 10 Mar 2015 15:26:43 +0000 (11:26 -0400)]
- Postgresql "functional" indexes are necessarily skipped from the
autogenerate process, as the SQLAlchemy backend currently does not
support reflection of these structures. A warning is emitted
both from the SQLAlchemy backend as well as from the Alembic
backend for Postgresql when such an index is detected.
fixes #282
Mike Bayer [Sat, 21 Feb 2015 00:20:53 +0000 (19:20 -0500)]
- Fixed bug where MySQL backend would report dropped unique indexes
and/or constraints as both at the same time. This is because
MySQL doesn't actually have a "unique constraint" construct that
reports differently than a "unique index", so it is present in both
lists. The net effect though is that the MySQL backend will report
a dropped unique index/constraint as an index in cases where the object
was first created as a unique constraint, if no other information
is available to make the decision. This differs from other backends
like Postgresql which can report on unique constraints and
unique indexes separately.
fixes #276
Mike Bayer [Mon, 9 Feb 2015 00:27:42 +0000 (19:27 -0500)]
- additional fix which impacts #267. fix filtered_heads() to accommodate
being given "heads" as the target so that it will in fact match when all heads
are given. fixes #267
Mike Bayer [Tue, 3 Feb 2015 16:40:40 +0000 (11:40 -0500)]
- move resolution of "starting rev" for --sql mode into
get_current_heads() directly; therefore we don't need to
do this in alembic.command, which we were doing for stamp but
not downgrade/upgrade. The slight change here is that the
context.get_starting_revision_argument() method will
return an abbreviated starting rev as abbreviated in
all cases, including the stamp command, where we previously
were converting a stamp argument first, but not for the
upgrade or downgrade commands.
- Fixed bug where using a partial revision identifier as the
"starting revision" in ``--sql`` mode in a downgrade operation
would fail to resolve properly. fixes #269
Mike Bayer [Sat, 24 Jan 2015 01:05:02 +0000 (20:05 -0500)]
- Added a new feature :attr:`.Config.attributes`, to help with the use
case of sharing state such as engines and connections on the outside
with a series of Alembic API calls; also added a new cookbook section
to describe this simple but pretty important use case.
Change single-quoting of floats in PostgreSQL compare_server_default
Do not wrap string defaults with single quotes when comparing against
columns of type float or numeric.
This fixes the crash occuring when the default of a float column is
an integer value (e.g., DEFAULT 5), while the Python server_default is
a string (e.g., server_default="5.0"). This results in the query
used in the comparison to throw a DataError ('SELECT 5 = '5.0').
Mike Bayer [Sat, 10 Jan 2015 22:08:03 +0000 (17:08 -0500)]
- The rendering of a :class:`~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
:class:`~sqlalchemy.schema.Table` object, so there's no step that
would resolve these Python-only key names to database column names.
fixes #259
Mike Bayer [Sat, 10 Jan 2015 21:32:17 +0000 (16:32 -0500)]
- 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.
fixes #260
Mike Bayer [Fri, 9 Jan 2015 16:26:36 +0000 (11:26 -0500)]
- changelog: 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. fixes #261
Mike Bayer [Tue, 30 Dec 2014 17:12:58 +0000 (12:12 -0500)]
- Fixed regression in new versioning system where upgrade / history
operation would fail on AttributeError if no version files were
present at all.
fixes #258