
==========
Changelog
==========

.. changelog::
    :version: 1.4.3
    :released: September 11, 2020

    .. change::
        :tags: bug, sqlite, batch
        :tickets: 711

        Added support to drop named CHECK constraints that are specified as part of
        a column, rather than table wide.  Previously, only constraints associated
        with the table were considered.

    .. change::
        :tags: bug, ops, mysql
        :tickets: 736

        Fixed issue where the MySQL dialect would not correctly render the server
        default of a column in an alter operation, if the operation were
        programmatically generated from an autogenerate pass as it would not
        accommodate for the full structure of the DefaultClause construct.

    .. change::
        :tags: bug, sqlite, batch
        :tickets: 697

        Fixed issue where the CAST applied to a JSON column when copying a SQLite
        table during batch mode would cause the data to be lost, as SQLite's CAST
        with JSON appears to convert the data to the value "0". The CAST is now
        skipped in a dialect-specific manner, including for JSON columns on SQLite.
        Pull request courtesy Sebastián Ramírez.

    .. change::
        :tags: bug, commands
        :tickets: 694

        The ``alembic current`` command no longer creates an ``alembic_version``
        table in the database if one does not exist already, returning no version
        as the current version. This allows checking for migrations in parallel
        without introducing race conditions.  Pull request courtesy Nikolay
        Edigaryev.


    .. change::
        :tags: bug, batch

        Fixed issue where columns in a foreign-key referenced table would be
        replaced with null-type columns during a batch operation; while this did
        not generally have any side effects, it could theoretically impact a batch
        operation that also targets that table directly and also would interfere
        with future changes to the ``.append_column()`` method to disallow implicit
        replacement of columns.

    .. change::
       :tags: bug, mssql
       :tickets: 716

       Fixed issue where the ``mssql_drop_foreign_key=True`` flag on
       ``op.drop_column`` would lead to incorrect syntax error due to a typo in the
       SQL emitted, same typo was present in the test as well so it was not
       detected. Pull request courtesy Oleg Shigorin.

.. changelog::
    :version: 1.4.2
    :released: March 19, 2020

    .. change::
        :tags: usecase, autogenerate
        :tickets: 669

        Adjusted autogen comparison to accommodate for backends that support
        computed column reflection, dependent on SQLAlchemy version 1.3.16 or
        higher. This emits a warning if the SQL expression inside of a
        :class:`.Computed` value changes between the metadata and the database, as
        these expressions can't be changed without dropping and recreating the
        column.


    .. change::
        :tags: bug, tests
        :tickets: 668

        Fixed an issue that prevented the test suite from running with the
        recently released py.test 5.4.0.


    .. change::
        :tags: bug, autogenerate, mysql
        :tickets: 671

        Fixed more false-positive failures produced by the new "compare type" logic
        first added in :ticket:`605`, particularly impacting MySQL string types
        regarding flags such as "charset" and "collation".

    .. change::
        :tags: bug, op directives, oracle
        :tickets: 670

        Fixed issue in Oracle backend where a table RENAME with a schema-qualified
        name would include the schema in the "to" portion, which is rejected by
        Oracle.


.. changelog::
    :version: 1.4.1
    :released: March 1, 2020

    .. change::
        :tags: bug, autogenerate
        :tickets: 661

        Fixed regression caused by the new "type comparison" logic introduced in
        1.4 as part of :ticket:`605` where comparisons of MySQL "unsigned integer"
        datatypes would produce false positives, as the regular expression logic
        was not correctly parsing the "unsigned" token when MySQL's default display
        width would be returned by the database.  Pull request courtesy Paul
        Becotte.

    .. change::
        :tags: bug, environment
        :tickets: 663

        Error message for "path doesn't exist" when loading up script environment
        now displays the absolute path.  Pull request courtesy Rowan Hart.

    .. change::
        :tags: bug, autogenerate
        :tickets: 654

        Fixed regression in 1.4.0 due to :ticket:`647` where unique constraint
        comparison with mixed case constraint names while not using a naming
        convention would produce false positives during autogenerate.

    .. change::
        :tags: bug, environment

        The check for matched rowcount when the alembic_version table is updated or
        deleted from is now conditional based on whether or not the dialect
        supports the concept of "rowcount" for UPDATE or DELETE rows matched.  Some
        third party dialects do not support this concept.  Pull request courtesy Ke
        Zhu.

    .. change::
        :tags: bug, operations
        :tickets: 655

        Fixed long-standing bug where an inline column CHECK constraint would not
        be rendered within an "ADD COLUMN" operation.  The DDL compiler is now
        consulted for inline constraints within the :meth:`.Operations.add_column`
        method as is done for regular CREATE TABLE operations.



.. changelog::
    :version: 1.4.0
    :released: February 4, 2020

    .. change::
        :tags: change

        The internal inspection routines no longer use SQLAlchemy's
        ``Inspector.from_engine()`` method, which is expected to be deprecated in
        1.4.  The ``inspect()`` function is now used.


    .. change::
        :tags: bug, autogenerate
        :tickets: 647

        Adjusted the unique constraint comparison logic in a similar manner as that
        of :ticket:`421` did for indexes in order to take into account SQLAlchemy's
        own truncation of long constraint names when a naming convention is in use.
        Without this step, a name that is truncated by SQLAlchemy based on a unique
        constraint naming convention or hardcoded name will not compare properly.


    .. change::
        :tags: feature, batch
        :tickets: 640

        Added new parameters :paramref:`.BatchOperations.add_column.insert_before`,
        :paramref:`.BatchOperations.add_column.insert_after` which provide for
        establishing the specific position in which a new column should be placed.
        Also added :paramref:`.Operations.batch_alter_table.partial_reordering`
        which allows the complete set of columns to be reordered when the new table
        is created.   Both operations apply only to when batch mode is recreating
        the whole table using ``recreate="always"``.  Thanks to Marcin Szymanski
        for assistance with the implementation.

    .. change::
        :tags: usecase, environment
        :tickets: 648

        Moved the use of the ``__file__`` attribute at the base of the Alembic
        package into the one place that it is specifically needed, which is when
        the config attempts to locate the template directory. This helps to allow
        Alembic to be fully importable in environments that are using Python
        memory-only import schemes.  Pull request courtesy layday.

    .. change::
        :tags: bug, autogenerate
        :tickets: 605

        A major rework of the "type comparison" logic is in place which changes the
        entire approach by which column datatypes are compared.  Types are now
        compared based on the DDL string generated by the metadata type vs. the
        datatype reflected from the database.  This means we compare types based on
        what would actually render and additionally if elements of the types change
        like string length, those changes are detected as well.  False positives
        like those generated between SQLAlchemy Boolean and MySQL TINYINT should
        also be resolved.   Thanks very much to Paul Becotte  for lots of hard work
        and patience on this one.

        .. seealso::

            :ref:`autogenerate_detects` - updated comments on type comparison

.. changelog::
    :version: 1.3.3
    :released: January 22, 2020

    .. change::
        :tags: bug, postgresql
        :tickets: 637

        Fixed issue where COMMENT directives for PostgreSQL failed to correctly
        include an explicit schema name, as well as correct quoting rules for
        schema, table, and column names.  Pull request courtesy Matthew Sills.

    .. change::
        :tags: usecase, operations
        :tickets: 624

        Added support for rendering of "computed" elements on :class:`.Column`
        objects, supported in SQLAlchemy via the new :class:`.Computed` element
        introduced in version 1.3.11. Pull request courtesy Federico Caselli.

        Note that there is currently no support for ALTER COLUMN to add, remove, or
        modify the "GENERATED ALWAYS AS" element from a column;  at least for
        PostgreSQL, it does not seem to be supported by the database. Additionally,
        SQLAlchemy does not currently reliably reflect the "GENERATED ALWAYS AS"
        phrase from an existing column, so there is also no autogenerate support
        for addition or removal of the :class:`.Computed` element to or from an
        existing column, there is only support for adding new columns that include
        the :class:`.Computed` element.  In the case that the :class:`.Computed`
        element is removed from the :class:`.Column` object in the table metadata,
        PostgreSQL and Oracle currently reflect the "GENERATED ALWAYS AS"
        expression as the "server default" which will produce an op that tries to
        drop the element as a default.

.. changelog::
    :version: 1.3.2
    :released: December 16, 2019

    .. change::
        :tags: bug, api, autogenerate
        :tickets: 635

        Fixed regression introduced by :ticket:`579` where server default rendering
        functions began to require a dialect implementation, however the
        :func:`.render_python_code` convenience function did not include one, thus
        causing the function to fail when used in a server default context.  The
        function now accepts a migration context argument and also creates one
        against the default dialect if one is not provided.


.. changelog::
    :version: 1.3.1
    :released: November 13, 2019

    .. change::
        :tags: bug, mssql
        :tickets: 621

        Fixed bug in MSSQL dialect where the drop constraint execution steps used
        to remove server default or implicit foreign key constraint failed to take
        into account the schema name of the target table.


.. changelog::
    :version: 1.3.0
    :released: October 31, 2019

    .. change::
        :tags: feature, command
        :tickets: 608

        Added support for ALEMBIC_CONFIG environment variable,
        refers to the location of the alembic configuration script
        in lieu of using the -c command line option.


    .. change::
        :tags: bug, autogenerate
        :tickets: 131

        Fixed bug in new Variant autogenerate where the order of the arguments to
        Variant were mistakenly reversed.

    .. change::
        :tags: change, compatibility

        Some internal modifications have been made to how the names of indexes and
        unique constraints work to make use of new functions added in SQLAlchemy
        1.4, so that SQLAlchemy has more flexibility over how naming conventions
        may be applied to these objects.

.. changelog::
    :version: 1.2.1
    :released: September 24, 2019

    .. change::
        :tags: bug, command
        :tickets: 601

        Reverted the name change of the "revisions" argument to
        :func:`.command.stamp` to "revision" as apparently applications are
        calling upon this argument as a keyword name.  Pull request courtesy
        Thomas Bechtold.  Special translations are also added to the command
        line interface so that it is still known as "revisions" in the CLI.

    .. change::
        :tags: bug, tests
        :tickets: 592

        Removed the "test requirements" from "setup.py test", as this command now
        only emits a removal error in any case and these requirements are unused.

.. changelog::
    :version: 1.2.0
    :released: September 20, 2019

    .. change::
        :tags: feature, command
        :tickets: 473

        Added new ``--purge`` flag to the ``alembic stamp`` command, which will
        unconditionally erase the version table before stamping anything.  This is
        useful for development where non-existent version identifiers might be left
        within the table.  Additionally, ``alembic.stamp`` now supports a list of
        revision identifiers, which are intended to allow setting up muliple heads
        at once.  Overall handling of version identifiers within the
        ``alembic.stamp`` command has been improved with many new tests and
        use cases added.

    .. change::
        :tags: bug, autogenerate
        :tickets: 550

        Improved the Python rendering of a series of migration operations such that
        a single "pass" is rendered for a :class:`.UpgradeOps` or
        :class:`.DowngradeOps` based on if no lines of Python code actually
        rendered under the operation, rather than whether or not sub-directives
        exist. Removed extra "pass" lines that would generate from the
        :class:`.ModifyTableOps` directive so that these aren't duplicated under
        operation rewriting scenarios.


    .. change::
        :tags: feature, runtime
        :tickets: 123

        Added new feature :meth:`.MigrationContext.autocommit_block`, a special
        directive which will provide for a non-transactional block inside of a
        migration script. The feature requres that: the database driver
        (e.g. DBAPI) supports the AUTOCOMMIT isolation mode.  The directive
        also necessarily needs to COMMIT the existing transaction in progress
        in order to enter autocommit mode.

        .. seealso::

            :meth:`.MigrationContext.autocommit_block`

    .. change::
        :tags: change: py3k

        Python 3.4 support is dropped, as the upstream tooling (pip, mysqlclient)
        etc are already dropping support for Python 3.4, which itself is no longer
        maintained.

    .. change::
        :tags: usecase, autogenerate
        :tickets: 518

        Added autogenerate support for :class:`.Column` objects that have
        dialect-specific ``**kwargs``, support first added in SQLAlchemy 1.3.
        This includes SQLite "on conflict" as well as options used by some
        third party dialects.

    .. change::
        :tags: usecase, autogenerate
        :tickets: 131

        Added rendering for SQLAlchemy ``Variant`` datatypes, which render as the
        base type plus one or more ``.with_variant()`` method calls.


    .. change::
        :tags: usecase, commands
        :tickets: 534

        Made the command interface revision lookup behavior more strict in that an
        Alembic revision number is only resolved based on a partial match rules if
        it has at least four characters, to prevent simple typographical issues
        from inadvertently  running migrations.

     .. change::
        :tags: feature, commands
        :tickets: 307

        Added "post write hooks" to revision generation.  These allow custom logic
        to run after a revision Python script is generated, typically for the
        purpose of running code formatters such as "Black" or "autopep8", but may
        be used for any arbitrary post-render hook as well, including custom Python
        functions or scripts.  The hooks are enabled by providing a
        ``[post_write_hooks]`` section in the alembic.ini file.  A single hook
        is provided which runs an arbitrary Python executable on the newly
        generated revision script, which can be configured to run code formatters
        such as Black; full examples are included in the documentation.

        .. seealso::

            :ref:`post_write_hooks`


    .. change::
        :tags: feature, environment
        :tickets: 463

        Added new flag ``--package`` to ``alembic init``.  For environments where
        the Alembic migration files and such are within the package tree and
        importable as modules, this flag can be specified which will add the
        additional ``__init__.py`` files in the version location and the
        environment location.

    .. change::
        :tags: bug, autogenerate
        :tickets: 549

        Fixed bug where rendering of comment text for table-level comments  within
        :meth:`.Operations.create_table_comment` and
        :meth:`.Operations.drop_table_comment` was not properly quote-escaped
        within rendered Python code for autogenerate.

    .. change::
        :tags: bug, autogenerate
        :tickets: 505

        Modified the logic of the :class:`.Rewriter` object such that it keeps a
        memoization of which directives it has processed, so that it can ensure it
        processes a particular directive only once, and additionally fixed
        :class:`.Rewriter` so that it functions correctly for multiple-pass
        autogenerate schemes, such as the one illustrated in the "multidb"
        template.  By tracking which directives have been processed, a
        multiple-pass scheme which calls upon the :class:`.Rewriter` multiple times
        for the same structure as elements are added can work without running
        duplicate operations on the same elements more than once.

.. changelog::
    :version: 1.1.0
    :released: August 26, 2019

    .. change::
        :tags: change

        Alembic 1.1 bumps the minimum version of SQLAlchemy to 1.1.   As was the
        case before, Python requirements remain at Python 2.7, or in the 3.x series
        Python 3.4.

    .. change::
        :tags: change, internals

        The test suite for Alembic now makes use of SQLAlchemy's testing framework
        directly.  Previously, Alembic had its own version of this framework that
        was mostly copied from that of SQLAlchemy to enable testing with older
        SQLAlchemy versions.  The majority of this code is now removed so that both
        projects can leverage improvements from a common testing framework.

    .. change::
        :tags: bug, commands
        :tickets: 562

        Fixed bug where the double-percent logic applied to some dialects such as
        psycopg2 would be rendered in ``--sql`` mode, by allowing dialect options
        to be passed through to the dialect used to generate SQL and then providing
        ``paramstyle="named"`` so that percent signs need not be doubled.   For
        users having this issue, existing env.py scripts need to add
        ``dialect_opts={"paramstyle": "named"}`` to their offline
        context.configure().  See the ``alembic/templates/generic/env.py`` template
        for an example.

    .. change::
        :tags: bug, py3k

        Fixed use of the deprecated "imp" module, which is used to detect  pep3147
        availability as well as to locate .pyc files, which started  emitting
        deprecation warnings during the test suite.   The warnings were not being
        emitted earlier during the test suite, the change is possibly due to
        changes in py.test itself but this is not clear. The check for pep3147 is
        set to True for any Python version 3.5 or greater now and importlib is used
        when available.  Note that some dependencies such as distutils may still be
        emitting this warning. Tests are adjusted to accommodate for dependencies
        that emit the warning as well.


    .. change::
        :tags: bug, mysql
        :tickets: 594

        Fixed issue where emitting a change of column name for MySQL did not
        preserve the column comment, even if it were specified as existing_comment.


    .. change::
        :tags: bug, setup
        :tickets: 592

        Removed the "python setup.py test" feature in favor of a straight run of
        "tox".   Per Pypa / pytest developers, "setup.py" commands are in general
        headed towards deprecation in favor of tox.  The tox.ini script has been
        updated such that running "tox" with no arguments will perform a single run
        of the test suite against the default installed Python interpreter.

        .. seealso::

            https://github.com/pypa/setuptools/issues/1684

            https://github.com/pytest-dev/pytest/issues/5534

    .. change::
        :tags: usecase, commands
        :tickets: 571

        The "alembic init" command will now proceed if the target directory exists
        as long as it's still empty.  Previously, it would not proceed if the
        directory existed. The new behavior is modeled from what git does, to
        accommodate for container or other deployments where an Alembic target
        directory may need to be already mounted instead of being created with
        alembic init.  Pull request courtesy Aviskar KC.



.. changelog::
    :version: 1.0.11
    :released: June 25, 2019

    .. change::
        :tags: bug, sqlite, autogenerate, batch
        :tickets: 579

        SQLite server default reflection will ensure parenthesis are surrounding a
        column default expression that is detected as being a non-constant
        expression, such as a ``datetime()`` default, to accommodate for the
        requirement that SQL expressions have to be parenthesized when being sent
        as DDL.  Parenthesis are not added to constant expressions to allow for
        maximum cross-compatibility with other dialects and existing test suites
        (such as Alembic's), which necessarily entails scanning the expression to
        eliminate for constant numeric and string values. The logic is added to the
        two "reflection->DDL round trip" paths which are currently autogenerate and
        batch migration.  Within autogenerate, the logic is on the rendering side,
        whereas in batch the logic is installed as a column reflection hook.


    .. change::
        :tags: bug, sqlite, autogenerate
        :tickets: 579

        Improved SQLite server default comparison to accommodate for a ``text()``
        construct that added parenthesis directly vs. a construct that relied
        upon the SQLAlchemy SQLite dialect to render the parenthesis, as well
        as improved support for various forms of constant expressions such as
        values that are quoted vs. non-quoted.


    .. change::
        :tags: bug, autogenerate

        Fixed bug where the "literal_binds" flag was not being set when
        autogenerate would create a server default value, meaning server default
        comparisons would fail for functions that contained literal values.

    .. change::
       :tags: bug, mysql
       :tickets: 554

       Added support for MySQL "DROP CHECK", which is added as of MySQL 8.0.16,
       separate from MariaDB's "DROP CONSTRAINT" for CHECK constraints.  The MySQL
       Alembic implementation now checks for "MariaDB" in server_version_info to
       decide which one to use.



    .. change::
        :tags: bug, mysql, operations
        :tickets: 564

        Fixed issue where MySQL databases need to use CHANGE COLUMN when altering a
        server default of CURRENT_TIMESTAMP, NOW() and probably other functions
        that are only usable with DATETIME/TIMESTAMP columns.  While MariaDB
        supports both CHANGE and ALTER COLUMN in this case, MySQL databases only
        support CHANGE.  So the new logic is that if the server default change is
        against a DateTime-oriented column, the CHANGE format is used
        unconditionally, as in the vast majority of cases the server default is to
        be CURRENT_TIMESTAMP which may also be potentially bundled with an "ON
        UPDATE CURRENT_TIMESTAMP" directive, which SQLAlchemy does not currently
        support as a distinct field.  The fix addiionally improves the server
        default comparison logic when the "ON UPDATE" clause is present and
        there are parenthesis to be adjusted for as is the case on some MariaDB
        versions.



    .. change::
        :tags: bug, environment

        Warnings emitted by Alembic now include a default stack level of 2, and in
        some cases it's set to 3, in order to help warnings indicate more closely
        where they are originating from.  Pull request courtesy Ash Berlin-Taylor.


    .. change::
        :tags: bug, py3k
        :tickets: 563

        Replaced the Python compatbility routines for ``getargspec()`` with a fully
        vendored version based on ``getfullargspec()`` from Python 3.3.
        Originally, Python was emitting deprecation warnings for this function in
        Python 3.8 alphas.  While this change was reverted, it was observed that
        Python 3 implementations for ``getfullargspec()`` are an order of magnitude
        slower as of the 3.4 series where it was rewritten against ``Signature``.
        While Python plans to improve upon this situation, SQLAlchemy projects for
        now are using a simple replacement to avoid any future issues.


.. changelog::
    :version: 1.0.10
    :released: April 28, 2019

    .. change::
       :tags: bug, commands
       :tickets: 552

       Fixed bug introduced in release 0.9.0 where the helptext for commands
       inadvertently got expanded to include function docstrings from the
       command.py module.  The logic has been adjusted to only refer to the first
       line(s) preceding the first line break within each docstring, as was the
       original intent.

    .. change::
        :tags: bug, operations, mysql
        :tickets: 551

        Added an assertion in :meth:`.RevisionMap.get_revisions` and other methods
        which ensures revision numbers are passed as strings or collections of
        strings.   Driver issues particularly on MySQL may inadvertently be passing
        bytes here which leads to failures later on.

    .. change::
        :tags: bug, autogenerate, mysql
        :tickets: 553

        Fixed bug when using the
        :paramref:`.EnvironmentContext.configure.compare_server_default` flag set
        to ``True`` where a server default that is introduced in the table metadata
        on an ``Integer`` column, where there is no existing server default in the
        database, would raise a ``TypeError``.

.. changelog::
    :version: 1.0.9
    :released: April 15, 2019

    .. change::
       :tags: bug, operations
       :tickets: 548

       Simplified the internal scheme used to generate the ``alembic.op`` namespace
       to no longer attempt to generate full method signatures (e.g. rather than
       generic ``*args, **kw``) as this was not working in most cases anyway, while
       in rare circumstances it would in fact sporadically have access to the real
       argument names and then fail when generating the function due to missing
       symbols in the argument signature.

.. changelog::
    :version: 1.0.8
    :released: March 4, 2019

    .. change::
       :tags: bug, operations
       :tickets: 528

       Removed use of deprecated ``force`` parameter for SQLAlchemy quoting
       functions as this parameter will be removed in a future release.
       Pull request courtesy Parth Shandilya(ParthS007).

    .. change::
       :tags: bug, autogenerate, postgresql, py3k
       :tickets: 541

       Fixed issue where server default comparison on the PostgreSQL dialect would
       fail for a blank string on Python 3.7 only, due to a change in regular
       expression behavior in Python 3.7.


.. changelog::
    :version: 1.0.7
    :released: January 25, 2019

    .. change::
       :tags: bug, autogenerate
       :tickets: 529

       Fixed issue in new comment support where autogenerated Python code
       for comments wasn't using ``repr()`` thus causing issues with
       quoting.  Pull request courtesy Damien Garaud.

.. changelog::
    :version: 1.0.6
    :released: January 13, 2019

    .. change::
        :tags: feature, operations
        :tickets: 422

        Added Table and Column level comments for supported backends.
        New methods :meth:`.Operations.create_table_comment` and
        :meth:`.Operations.drop_table_comment` are added.  A new arguments
        :paramref:`.Operations.alter_column.comment` and
        :paramref:`.Operations.alter_column.existing_comment` are added to
        :meth:`.Operations.alter_column`.   Autogenerate support is also added
        to ensure comment add/drops from tables and columns are generated as well
        as that :meth:`.Operations.create_table`, :meth:`.Operations.add_column`
        both include the comment field from the source :class:`.Table`
        or :class:`.Column` object.

.. changelog::
    :version: 1.0.5
    :released: November 27, 2018

    .. change::
        :tags: bug, py3k
        :tickets: 507

        Resolved remaining Python 3 deprecation warnings, covering
        the use of inspect.formatargspec() with a vendored version
        copied from the Python standard library, importing
        collections.abc above Python 3.3 when testing against abstract
        base classes, fixed one occurrence of log.warn(), as well as a few
        invalid escape sequences.

.. changelog::
    :version: 1.0.4
    :released: November 27, 2018

    .. change::
       :tags: change

       Code hosting has been moved to GitHub, at
       https://github.com/sqlalchemy/alembic.  Additionally, the
       main Alembic website documentation URL is now
       https://alembic.sqlalchemy.org.

.. changelog::
    :version: 1.0.3
    :released: November 14, 2018

    .. change::
        :tags: bug, mssql
        :tickets: 516

       Fixed regression caused by :ticket:`513`, where the logic to consume
       ``mssql_include`` was not correctly interpreting the case where the flag
       was not present, breaking the ``op.create_index`` directive for SQL Server
       as a whole.

.. changelog::
    :version: 1.0.2
    :released: October 31, 2018

    .. change::
       :tags: bug, autogenerate
       :tickets: 515

       The ``system=True`` flag on :class:`.Column`, used primarily in conjunction
       with the Postgresql "xmin" column, now renders within the autogenerate
       render process, allowing the column to be excluded from DDL.  Additionally,
       adding a system=True column to a model will produce no autogenerate diff as
       this column is implicitly present in the database.

    .. change::
       :tags: bug, mssql
       :tickets: 513

       Fixed issue where usage of the SQL Server ``mssql_include`` option within a
       :meth:`.Operations.create_index` would raise a KeyError, as the additional
       column(s) need to be added to the table object used by the construct
       internally.

.. changelog::
    :version: 1.0.1
    :released: October 17, 2018

    .. change::
        :tags: bug, commands
        :tickets: 497

        Fixed an issue where revision descriptions were essentially
        being formatted twice. Any revision description that contained
        characters like %, writing output to stdout will fail because
        the call to config.print_stdout attempted to format any
        additional args passed to the function.
        This fix now only applies string formatting if any args are provided
        along with the output text.

    .. change::
       :tags: bug, autogenerate
       :tickets: 512

       Fixed issue where removed method ``union_update()`` was used when a
       customized :class:`.MigrationScript` instance included entries in the
       ``.imports`` data member, raising an AttributeError.


.. changelog::
    :version: 1.0.0
    :released: July 13, 2018
    :released: July 13, 2018
    :released: July 13, 2018

    .. change::
        :tags: feature, general
        :tickets: 491

        For Alembic 1.0, Python 2.6 / 3.3 support is being dropped, allowing a
        fixed setup.py to be built as well as universal wheels.  Pull request
        courtesy Hugo.




    .. change::
        :tags: feature, general

        With the 1.0 release, Alembic's minimum SQLAlchemy support version
        moves to 0.9.0, previously 0.7.9.

    .. change::
        :tags: bug, batch
        :tickets: 502

        Fixed issue in batch where dropping a primary key column, then adding it
        back under the same name but without the primary_key flag, would not remove
        it from the existing PrimaryKeyConstraint.  If a new PrimaryKeyConstraint
        is added, it is used as-is, as was the case before.

.. changelog::
    :version: 0.9.10
    :released: June 29, 2018

    .. change::
        :tags: bug, autogenerate

        The "op.drop_constraint()" directive will now render using ``repr()`` for
        the schema name, in the same way that "schema" renders for all the other op
        directives.  Pull request courtesy Denis Kataev.

    .. change::
        :tags: bug, autogenerate
        :tickets: 494

        Added basic capabilities for external dialects to support rendering of
        "nested" types, like arrays, in a manner similar to that of the Postgresql
        dialect.

    .. change::
        :tags: bug, autogenerate

        Fixed issue where "autoincrement=True" would not render for a column that
        specified it, since as of SQLAlchemy 1.1 this is no longer the default
        value for "autoincrement".  Note the behavior only takes effect against the
        SQLAlchemy 1.1.0 and higher; for pre-1.1 SQLAlchemy, "autoincrement=True"
        does not render as was the case before. Pull request courtesy  Elad Almos.

.. changelog::
    :version: 0.9.9
    :released: March 22, 2018

    .. change::
        :tags: feature, commands
        :tickets: 481

        Added new flag ``--indicate-current`` to the ``alembic history`` command.
        When listing versions, it will include the token "(current)" to indicate
        the given version is a current head in the target database.  Pull request
        courtesy Kazutaka Mise.

    .. change::
        :tags: bug, autogenerate, mysql
        :tickets: 455

        The fix for :ticket:`455` in version 0.9.6 involving MySQL server default
        comparison was entirely non functional, as the test itself was also broken
        and didn't reveal that it wasn't working. The regular expression to compare
        server default values like CURRENT_TIMESTAMP to current_timestamp() is
        repaired.

    .. change::
        :tags: bug, mysql, autogenerate
        :tickets: 483

        Fixed bug where MySQL server default comparisons were basically not working
        at all due to incorrect regexp added in :ticket:`455`.  Also accommodates
        for MariaDB 10.2 quoting differences in reporting integer based server
        defaults.




    .. change::
        :tags: bug, operations, mysql
        :tickets: 487

        Fixed bug in ``op.drop_constraint()`` for MySQL where
        quoting rules would not be applied to the constraint name.

.. changelog::
    :version: 0.9.8
    :released: February 16, 2018

    .. change::
        :tags: bug, runtime
        :tickets: 482

        Fixed bug where the :meth:`.Script.as_revision_number` method
        did not accommodate for the 'heads' identifier, which in turn
        caused the :meth:`.EnvironmentContext.get_head_revisions`
        and :meth:`.EnvironmentContext.get_revision_argument` methods
        to be not usable when multiple heads were present.
        The :meth:.`EnvironmentContext.get_head_revisions` method returns
        a tuple in all cases as documented.



    .. change::
        :tags: bug, postgresql, autogenerate
        :tickets: 478

        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')``.

    .. change::
        :tags: bug, autogenerate
        :tickets: 468

        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.

    .. change::
        :tags: bug, postgresql
        :tickets: 480

        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.

    .. change::
        :tags: bug, mysql
        :tickets: 479

        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.

.. changelog::
    :version: 0.9.7
    :released: January 16, 2018

    .. change::
        :tags: bug, autogenerate
        :tickets: 472

        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.   Works with
        SQLAlchemy 0.9 and later series.


    .. change::
        :tags: bug, postgresql, autogenerate
        :tickets: 461

        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.



.. changelog::
    :version: 0.9.6
    :released: October 13, 2017

    .. change::
        :tags: bug, commands
        :tickets: 458

        Fixed a few Python3.6 deprecation warnings by replacing ``StopIteration``
        with ``return``, as well as using ``getfullargspec()`` instead of
        ``getargspec()`` under Python 3.

    .. change::
        :tags: bug, commands
        :tickets: 441

        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.

    .. change::
        :tags: bug, autogenerate
        :tickets: 442

        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.

    .. change::
        :tags: bug, mysql
        :tickets: 455

        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.

    .. change::
        :tags: bug, autogenerate

        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.

    .. change::
        :tags: feature, commands
        :tickets: 447

        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.

    .. change::
        :tags: bug, batch
        :tickets: 457

        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.

    .. change::
        :tags: bug, autogenerate
        :tickets: 456

        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.

    .. change::
        :tags: bug, runtime, py3k
        :tickets: 449

        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.

.. changelog::
    :version: 0.9.5
    :released: August 9, 2017

    .. change::
        :tags: bug, commands
        :tickets: 441

        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.

    .. change::
        :tags: bug, postgresql
        :tickets: 424

        Added support for the dialect-specific keyword arguments
        to :meth:`.Operations.drop_index`.   This includes support for
        ``postgresql_concurrently`` and others.

    .. change::
        :tags: bug, commands

        Fixed bug in timezone feature introduced in
        :ticket:`425` when the creation
        date in a revision file is calculated, to
        accommodate for timezone names that contain
        mixed-case characters in their name as opposed
        to all uppercase.  Pull request courtesy Nils
        Philippsen.

.. changelog::
    :version: 0.9.4
    :released: July 31, 2017

    .. change::
      :tags: bug, runtime

      Added an additional attribute to the new
      :paramref:`.EnvironmentContext.configure.on_version_apply` API,
      :attr:`.MigrationInfo.up_revision_ids`, to accommodate for the uncommon
      case of the ``alembic stamp`` command being used to move from multiple
      branches down to a common branchpoint; there will be multiple
      "up" revisions in this one case.

.. changelog::
    :version: 0.9.3
    :released: July 6, 2017

    .. change::
      :tags: feature, runtime

      Added a new callback hook
      :paramref:`.EnvironmentContext.configure.on_version_apply`,
      which allows user-defined code to be invoked each time an individual
      upgrade, downgrade, or stamp operation proceeds against a database.
      Pull request courtesy John Passaro.

    .. change:: 433
      :tags: bug, autogenerate
      :tickets: 433

      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.

    .. change:: 431
      :tags: bug, tests
      :tickets: 431

      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.

.. changelog::
    :version: 0.9.2
    :released: May 18, 2017

    .. change:: 429
      :tags: bug, mssql
      :tickets: 429

      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.

    .. change:: 425
      :tags: feature, commands
      :tickets: 425

      Added a new configuration option ``timezone``, a string timezone name
      that will be applied to the create date timestamp rendered
      inside the revision file as made availble to the ``file_template`` used
      to generate the revision filename.  Note this change adds the
      ``python-dateutil`` package as a dependency.

    .. change:: 421
      :tags: bug, autogenerate
      :tickets: 421

      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.

    .. change:: 419
      :tags: bug environment
      :tickets: 419

      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`.

.. changelog::
    :version: 0.9.1
    :released: March 1, 2017

    .. change:: 417
      :tags: bug, commands
      :tickets: 417, 369

      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.

.. changelog::
    :version: 0.9.0
    :released: February 28, 2017

    .. change:: 38
      :tags: feature, autogenerate
      :tickets: 38

      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.

    .. change:: 369
      :tags: bug, commands
      :tickets: 369

      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.

    .. change:: 413
      :tags: bug, autogenerate, mysql
      :tickets: 413

      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.

    .. change:: 411
      :tags: bug, postgresql
      :tickets: 411

      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`.

    .. change:: 85
      :tags: bug, postgresql
      :tickets: 85

      Fixed bug where Postgresql ARRAY type would not render the import prefix
      for the inner type; additionally, user-defined renderers take place
      for the inner type as well as the outer type.  Pull request courtesy
      Paul Brackin.

    .. change:: process_revision_directives_command
      :tags: feature, autogenerate

      Added a keyword argument ``process_revision_directives`` to the
      :func:`.command.revision` API call.  This function acts in the
      same role as the environment-level
      :paramref:`.EnvironmentContext.configure.process_revision_directives`,
      and allows API use of the
      command to drop in an ad-hoc directive process function.  This
      function can be used among other things to place a complete
      :class:`.MigrationScript` structure in place.

    .. change:: 412
      :tags: feature, postgresql
      :tickets: 412

      Added support for Postgresql EXCLUDE constraints, including the
      operation directive :meth:`.Operations.create_exclude_constraints`
      as well as autogenerate render support for the ``ExcludeConstraint``
      object as present in a ``Table``.  Autogenerate detection for an EXCLUDE
      constraint added or removed to/from an existing table is **not**
      implemented as the SQLAlchemy Postgresql dialect does not yet support
      reflection of EXCLUDE constraints.

      Additionally, unknown constraint types now warn when
      encountered within an autogenerate action rather than raise.

    .. change:: fk_schema_compare
      :tags: bug, operations

      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.

.. changelog::
    :version: 0.8.10
    :released: January 17, 2017

    .. change:: 406
      :tags: bug, versioning
      :tickets: 406

      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.

    .. change:: 402
      :tags: bug, batch
      :tickets: 402

      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.

    .. change:: update_uq_dedupe
      :tags: bug, autogenerate, oracle

      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.

    .. change:: 356
      :tags: bug, versioning
      :tickets: 356

      Added a file ignore for Python files of the form ``.#<name>.py``,
      which are generated by the Emacs editor.  Pull request courtesy
      Markus Mattes.

.. changelog::
    :version: 0.8.9
    :released: November 28, 2016

    .. change::  393
      :tags: bug, autogenerate
      :tickets: 393

      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.

    .. change::
      :tags: bug, batch
      :tickets: 391

      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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     