Mike Bayer [Sat, 9 Apr 2016 01:32:07 +0000 (21:32 -0400)]
- 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.
fixes #367
Mike Bayer [Mon, 21 Mar 2016 18:25:49 +0000 (14:25 -0400)]
- 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.
fixes #365
- test against uuid_generate_v4() directly, but this requires extensions
to be installed. should come up with a built in function for this test
Mike Bayer [Fri, 22 Jan 2016 18:04:27 +0000 (13:04 -0500)]
- 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.
fixes #354
- 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.
fixes #355
Mike Bayer [Tue, 15 Dec 2015 17:37:04 +0000 (12:37 -0500)]
- 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.
fixes #345
Mike Bayer [Thu, 10 Dec 2015 17:15:23 +0000 (12:15 -0500)]
- existing_server_default is not used to drop the previous
schema type constraint; existing_type is. I haven't checked to
see if this changed at some point but that's what the source code
right now says.
Mike Bayer [Tue, 8 Dec 2015 20:01:15 +0000 (15:01 -0500)]
- document that the value we pass to set_section_option and set_main_option
is in fact subject to variable interpolation, so raw percents must be doubled.
- add a test demonstrating the use of interpolation.
Mike Bayer [Sat, 5 Dec 2015 20:02:20 +0000 (15:02 -0500)]
- Added a type-level comparator that distinguishes :class:`.Integer`,
:class:`.BigInteger`, and :class:`.SmallInteger` types and
dialect-specific types; these all have "Integer" affinity so previously
all compared as the same.
fixes #341
antti_haapala [Sun, 29 Nov 2015 16:27:57 +0000 (16:27 +0000)]
prettier revision identifier (always exatly 12 hex digits long) with better guaranteed entropy (the last 48 bits of a uuid4 are all random). Works everywhere where uuid module exists (2.5 -)
Rationale: with the current code most revision ids start with 1, 2, 3 or 4, and there are far more collisions with 2 initial digits than necessary (cumbersome to check a file by revision on command line and such). So instead of revision ids that are 1-12 digits long with ~45 bits of information, lets just have them 12 digits long and contain full 48 bits of info.
Mike Bayer [Fri, 30 Oct 2015 16:12:07 +0000 (12:12 -0400)]
- Adjusted the rendering for index expressions such that a :class:`.Column`
object present in the source :class:`.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.
fixes #337
Jacob Magnusson [Thu, 29 Oct 2015 11:14:20 +0000 (12:14 +0100)]
Autogenerate renderer for op.ExecuteSQLOp
Asserts that the passed in sqltext is a string to simplify the
implementation. Generates a op.execute(sqltext) line.
Mike Bayer [Fri, 16 Oct 2015 16:29:32 +0000 (12:29 -0400)]
- 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
:attr:`.AutogenContext.imports` and the documentation is repaired.
fixes #332
Mike Bayer [Fri, 16 Oct 2015 16:06:01 +0000 (12:06 -0400)]
- 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.
fixes #333
Mike Bayer [Thu, 3 Sep 2015 01:52:33 +0000 (21:52 -0400)]
- 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.
fixes #324
Mike Bayer [Tue, 25 Aug 2015 16:11:19 +0000 (12:11 -0400)]
- 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.
fixes #321
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