Mike Bayer [Wed, 11 Jan 2017 14:33:01 +0000 (09:33 -0500)]
Add primary key constraint to alembic_version
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
:paramref:`.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.
mike bayer [Thu, 12 Jan 2017 18:47:55 +0000 (13:47 -0500)]
Merge "- test py36 - Current mysqlclient does not accept "bytes" on py3k, SQLAlchemy 0.9 still lists this client (the original mysqldb version) as "supports_unicode_statements=False" so is no longer functional on py3k. - Rollback transaction after table drop; it seems py3.6 sqlite3 suddenly turned on transactional DDL for SQLite"
Mike Bayer [Wed, 11 Jan 2017 15:29:57 +0000 (10:29 -0500)]
- test py36
- Current mysqlclient does not accept "bytes" on py3k, SQLAlchemy 0.9
still lists this client (the original mysqldb version) as
"supports_unicode_statements=False" so is no longer functional on py3k.
- Rollback transaction after table drop; it seems py3.6 sqlite3
suddenly turned on transactional DDL for SQLite
Mike Bayer [Tue, 3 Jan 2017 21:24:42 +0000 (16:24 -0500)]
Generalize uq -> uix dedupe logic
Adjusted the logic originally added for :ticket:`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.
Mike Bayer [Mon, 19 Dec 2016 16:04:43 +0000 (11:04 -0500)]
Ensure primary_key flag unset for PK batch drop
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.
Mike Bayer [Wed, 23 Nov 2016 19:42:19 +0000 (14:42 -0500)]
cast() types in batch only if type_affinity is different
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.
Jiri Kuncar [Fri, 18 Nov 2016 18:40:24 +0000 (13:40 -0500)]
Detect and ignore duplicate revision files on read
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.
Maico Timmerman [Tue, 15 Nov 2016 20:39:18 +0000 (15:39 -0500)]
Add single pound to generated comments
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.
Mike Bayer [Wed, 9 Nov 2016 13:42:12 +0000 (08:42 -0500)]
Compare to metadata_impl in compare_type() to guard against custom TypeDecorator
Fixed bug where usage of a custom TypeDecorator which returns a
per-dialect type via :meth:`.TypeDecorator.load_dialect_impl` that differs
significantly from the default "impl" for the type decorator would fail
to compare correctly during autogenerate.
Mike Bayer [Fri, 28 Oct 2016 13:17:42 +0000 (09:17 -0400)]
Unwrap unaryexpression when testing for functional index
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.
Frazer McLean [Fri, 17 Jun 2016 16:55:11 +0000 (12:55 -0400)]
Support USING for Postgresql ALTER COLUMN.
Added support for the USING clause to the ALTER COLUMN operation
for Postgresql. Support is via the
:paramref:`.op.alter_column.postgresql_using`
parameter.
Mike Bayer [Mon, 22 Aug 2016 15:22:28 +0000 (11:22 -0400)]
Move op tests for Postgresql to test_postgresql
This moves tests for op features specific to Postgresql.
Note this does not include tests in test_op that
make use of the postgresql backend just for "schema" support.
Mike Bayer [Mon, 18 Jul 2016 21:17:53 +0000 (17:17 -0400)]
Don't raise RangeNotAncestor for sibling branches
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.
When we're about to claim an error due to
"alembic upgrade greater to lower", make sure this
isn't a request to hit a node in a different branch
that's already implied.
Mike Bayer [Tue, 12 Jul 2016 19:05:09 +0000 (15:05 -0400)]
Don't remove dependent version when downgrading to a version.
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 :ticket:`377`
and :ticket:`378` to improve treatment of branches with dependencies
overall.
Mike Bayer [Sun, 10 Jul 2016 20:23:21 +0000 (16:23 -0400)]
Detect downgrades over dependencies distinctly from unmerge
Previously, a downgrade to a version that is also a dependency
to another branch, where that branch is advanced beyond
the target, would fail to be downgraded, as this would
be detected as an "umerge" even though the target version
to be INSERTed would not be present.
The patch replaces the existing heuristic
that checks for "delete" with a new one that calculates
a potential "unmerge" fully, and returns False only if we in
fact could do an unmerge.
Also change the string display of a version so that we don't
display misleading target versions that might not actually
be getting invoked.
Mike Bayer [Mon, 11 Jul 2016 19:27:45 +0000 (15:27 -0400)]
Report on other branch dependencies in "current"
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 on different branches from the top-level
versions listed in the alembic_version table.
Mike Bayer [Wed, 29 Jun 2016 20:22:24 +0000 (16:22 -0400)]
Don't remove None for default schema of None
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.
Mike Bayer [Wed, 1 Jun 2016 22:07:40 +0000 (18:07 -0400)]
- 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.
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