Mike Bayer [Fri, 4 Aug 2017 17:28:56 +0000 (13:28 -0400)]
Raise if manual revision id contains dashes or at signs
A :class:`.CommandError` is raised if the "--rev-id" passed to the
:func:`.revision` command contains dashes or at-signs, as this interferes
with the command notation used to locate revisions.
* add callback tests with stamp present
* fix bug in stamp MigrationInfo construction
* adjust MigrationInfo API to reflect existence of stamps with multiple
up revisions
Mike Bayer [Fri, 2 Jun 2017 14:20:27 +0000 (10:20 -0400)]
Adjust for Variant returning itself as impl
Fixed bug where autogen comparison of a :class:`.Variant` datatype
would not compare to the dialect level type for the "default"
implementation of the :class:`.Variant`, returning the type as changed
between database and table metadata.
Mike Bayer [Wed, 31 May 2017 21:12:41 +0000 (17:12 -0400)]
- 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.
Mike Bayer [Thu, 18 May 2017 14:36:13 +0000 (10:36 -0400)]
Don't use schema with second argument, SQL Server sp_rename
Repaired :meth:`.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.
Also added some extra tests for sp_rename w/ quoting / case sensitive
names.
Mike Bayer [Wed, 15 Mar 2017 21:10:28 +0000 (17:10 -0400)]
Apply DDLCompiler name rules to Index for autogenerate
The autogenerate compare scheme now takes into account the name truncation
rules applied by SQLAlchemy's DDL compiler to the names of the
:class:`.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.
Mike Bayer [Sat, 4 Mar 2017 21:42:30 +0000 (16:42 -0500)]
Warn on non-Connection present and accommodate for Engine
A warning is emitted when an object that's not a
:class:`~sqlalchemy.engine.Connection` is passed to
:meth:`.EnvironmentContext.configure`. For the case of a
:class:`~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
:class:`~sqlalchemy.engine.Engine` and not a
:class:`~sqlalchemy.engine.Connection`.
Mike Bayer [Wed, 1 Mar 2017 06:14:50 +0000 (01:14 -0500)]
Don't raise on open transaction if we already started in one
An adjustment to the bug fix for :ticket:`369` to accommodate for
env.py scripts that use an enclosing transaction distinct from the
one that the context provides, so that the check for "didn't commit
the transaction" doesn't trigger in this scenario.
Mike Bayer [Thu, 23 Feb 2017 17:57:40 +0000 (12:57 -0500)]
Allow target_metadata to be a sequence
The :paramref:`.EnvironmentContext.configure.target_metadata` parameter
may now be optionally specified as a sequence of :class:`.MetaData`
objects instead of a single :class:`.MetaData` object. The
autogenerate process will process the sequence of :class:`.MetaData`
objects in order.
Mike Bayer [Thu, 23 Feb 2017 16:18:57 +0000 (11:18 -0500)]
Detect open transaction at end of migration w/ transactional_ddl=False
A :class:`.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.
Mike Bayer [Wed, 22 Feb 2017 21:59:09 +0000 (16:59 -0500)]
Apply subtype repr logic to JSON/JSONB
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 :ticket:`85`.
Also modifies the ARRAY approach from :ticket:`85` to be
regular expression based for safer targeting of the inner
repr() type.
Mike Bayer [Mon, 20 Feb 2017 21:54:07 +0000 (16:54 -0500)]
Add ExcludeConstraint support for Postgresql
Add full support for Postgresql add_exclude_constraint().
This opens up more of the operations API and serves as a
model for other dialect-specific constraints.
Additionally, gracefully degrade if a given constraint
class is not supported with a warning.
Mike Bayer [Wed, 22 Feb 2017 17:51:53 +0000 (12:51 -0500)]
Detect and render autoincrement for alter_column()
The ``autoincrement=True`` flag is now rendered within the
:meth:`.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.
Mike Bayer [Mon, 30 Jan 2017 14:34:52 +0000 (09:34 -0500)]
Add process_revision_directives param to command.revision()
This allows programmatic use of command.revision() to
specify an ad-hoc process_revision_directives callable,
rather than having it placed via the env.py script.
Paul [Mon, 20 Feb 2017 20:20:17 +0000 (15:20 -0500)]
Fix postgresql automigration for ARRAY types
Adds a new codepath into render._repr_type() that will consult
the dialect impl for specific types. On the postgresql side,
the exisiting repr() is combined with a replace featuring
the full autogen render of the nested type.
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #85
Change-Id: I8796bfeea27d48e6f8bb5ea4562bdc04961ba0d5
Pull-request: https://github.com/zzzeek/alembic/pull/38
Ensure schema names also compared in foreign_key_constraint()
Fixed bug in :func:`.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.
Mike Bayer [Mon, 23 Jan 2017 19:24:31 +0000 (14:24 -0500)]
- add a new section "Run Multiple Alembic Environments from one .ini file",
clarify what the --name flag does and how this differs from
"multiple bases".
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.