Mike Bayer [Fri, 26 Jan 2018 15:02:16 +0000 (10:02 -0500)]
Add HSTORE to render_type_w_subtype
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.
Mike Bayer [Tue, 23 Jan 2018 17:38:28 +0000 (12:38 -0500)]
Detect indexes for table that's dropped
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.
Mike Bayer [Tue, 23 Jan 2018 22:33:49 +0000 (17:33 -0500)]
Add DROP CONSTRAINT to MySQL for mariadb
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.
Mike Bayer [Mon, 22 Jan 2018 19:40:23 +0000 (14:40 -0500)]
Render ExcludeContraint Column as column, not plain string
Fixed bug where autogenerate of :class:`.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')``.
Mike Bayer [Tue, 2 Jan 2018 22:10:43 +0000 (17:10 -0500)]
Disable index quoting when applying truncated DDL rules
Fixed regression caused by :ticket:`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.
Mike Bayer [Wed, 25 Oct 2017 19:24:29 +0000 (15:24 -0400)]
Resolve Postgresql implicit indexes via duplicates_constraint
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.
Mike Bayer [Wed, 11 Oct 2017 21:17:19 +0000 (17:17 -0400)]
Clean up all Python 3.6 warnings
Fixed a few Python3.6 deprecation warnings by replacing ``StopIteration``
with ``return``, as well as using ``getfullargspec()`` instead of
``getargspec()`` under Python 3.
Additionally fixed docstrings with backslashes needing r'', filehandles
not explicitly closed, accommodate for .pyc files not necessarily present.
Mike Bayer [Wed, 11 Oct 2017 13:53:22 +0000 (09:53 -0400)]
Clean up _fk_colspec() for link_to_name, no column found
A :class:`.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.
Mike Bayer [Wed, 11 Oct 2017 14:08:19 +0000 (10:08 -0400)]
Append table name to batch temp name
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.
Mike Bayer [Wed, 4 Oct 2017 20:01:33 +0000 (16:01 -0400)]
Accommodate for mariadb 10.2 function reflection style
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.
Also implement mariadb 10.2 checks from SQLAlchemy to skip
other CHECK contraint related tests that can't pass.
Mike Bayer [Sat, 16 Sep 2017 00:25:43 +0000 (20:25 -0400)]
Add + to illegal revision characters list
An addition to :ticket:`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.
Mike Bayer [Thu, 7 Sep 2017 21:43:00 +0000 (17:43 -0400)]
Support pep3149, latest import mechanics, fully
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.
Mike Bayer [Wed, 6 Sep 2017 14:20:39 +0000 (10:20 -0400)]
Use env in history when revision_history=true
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.
pg3-ivan [Fri, 25 Aug 2017 14:02:31 +0000 (10:02 -0400)]
Don't compare scale if Numeric has no precision
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.
Mike Bayer [Wed, 16 Aug 2017 14:26:16 +0000 (10:26 -0400)]
Add generic per-type rendering, implement ARRAY
Fixed bug expanding upon the fix for
:ticket:`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.
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".