Mike Bayer [Sun, 23 Nov 2014 20:35:12 +0000 (15:35 -0500)]
- The ``alembic revision`` command accepts the ``--sql`` option to
suit some very obscure use case where the ``revision_environment``
flag is set up, so that ``env.py`` is run when ``alembic revision``
is run even though autogenerate isn't specified. As this flag is
otherwise confusing, error messages are now raised if
``alembic revision`` is invoked with both ``--sql`` and
``--autogenerate`` or with ``--sql`` without
``revision_environment`` being set.
fixes #248
Mike Bayer [Sun, 23 Nov 2014 20:23:52 +0000 (15:23 -0500)]
- Relative revision identifiers as used with ``alembic upgrade``,
``alembic downgrade`` and ``alembic history`` can be combined with
specific revisions as well, e.g. ``alembic upgrade ae10+3``, to produce
a migration target relative to the given exact version.
Mike Bayer [Sat, 22 Nov 2014 20:39:44 +0000 (15:39 -0500)]
- now that branching is an enormous chapter, break out the docs into
individual pages. the pages here are a little slim in the middle
but overall the one-page docs were getting extremely long.
Mike Bayer [Sat, 22 Nov 2014 19:58:09 +0000 (14:58 -0500)]
- In conjunction with support for multiple independent bases, the
specific version directories are now also configurable to include
multiple, user-defined directories. When multiple directories exist,
the creation of a revision file with no down revision requires
that the starting directory is indicated; the creation of subsequent
revisions along that lineage will then automatically use that
directory for new files.
fixes #124
Mike Bayer [Sat, 22 Nov 2014 16:49:20 +0000 (11:49 -0500)]
- break out the concept of "down revision" into two pieces:
down_revision and "dependencies". For migration traversal, the downrevs
we care about are the union of these two sets. however for location of nodes
and branch labeling, we look only at down_revsion. this works really well
and allows us to have mutually-dependent trees that can easily be itererated
independently of each other. docs are needed
Mike Bayer [Sat, 22 Nov 2014 13:59:27 +0000 (08:59 -0500)]
- support the case where a mergepoint has a branchpoint immediately
following it; this will be the norm in the case where parallel
branches refer to each other as dependencies.
this means we need to limit for from/to revisions based on current
heads / ancestors of those heads whenever we merge/unmerge.
Mike Bayer [Fri, 21 Nov 2014 19:20:36 +0000 (14:20 -0500)]
- Added a rule for Postgresql to not render a "drop unique" and "drop index"
given the same name; for now it is assumed that the "index" is the
implicit one Postgreql generates. Future integration with
new SQLAlchemy 1.0 features will improve this to be more
resilient.
fixes #247
Mike Bayer [Fri, 21 Nov 2014 18:22:05 +0000 (13:22 -0500)]
- A change in the ordering when columns and constraints are dropped;
autogenerate will now place the "drop constraint" calls *before*
the "drop column" calls, so that columns involved in those constraints
still exist when the constraint is dropped.
fixes #247
Mike Bayer [Thu, 20 Nov 2014 23:08:02 +0000 (18:08 -0500)]
- The "multiple heads / branches" feature has now landed. This is
by far the most significant change Alembic has seen since its inception;
while the workflow of most commands hasn't changed, and the format
of version files and the ``alembic_version`` table are unchanged as well,
a new suite of features opens up in the case where multiple version
files refer to the same parent, or to the "base". Merging of
branches, operating across distinct named heads, and multiple
independent bases are now all supported. The feature incurs radical
changes to the internals of versioning and traversal, and should be
treated as "beta mode" for the next several subsequent releases
within 0.7.
fixes #167
Mike Bayer [Mon, 17 Nov 2014 02:44:16 +0000 (21:44 -0500)]
- Fixed a variety of issues surrounding rendering of Python code that
contains unicode literals. The first is that the "quoted_name" construct
that SQLAlchemy uses to represent table and column names as well
as schema names does not ``repr()`` correctly on Py2K when the value
contains unicode characters; therefore an explicit stringification is
added to these. Additionally, SQL expressions such as server defaults
were not being generated in a unicode-safe fashion leading to decode
errors if server defaults contained non-ascii characters.
fixes #243
Mike Bayer [Sun, 9 Nov 2014 03:42:07 +0000 (22:42 -0500)]
- add a little step to get PG to work rudimentally, however
the drop + recreate routine still needs a solution for refernential
integrity for it to be of general use
Mike Bayer [Sat, 8 Nov 2014 23:59:28 +0000 (18:59 -0500)]
- start docs
- run tests against mysql/PG to make sure auto mode works at least, try
a proof of concept recreate for MySQL. recreate doesn't work on PG
as constraint names are global (ugh). Will have to figure something
out on that.
Mike Bayer [Sat, 8 Nov 2014 23:06:26 +0000 (18:06 -0500)]
- The :class:`~sqlalchemy.schema.Table` object is now returned when
the :meth:`.Operations.create_table` method is used. This ``Table``
is suitable for use in subsequent SQL operations, in particular
the :meth:`.Operations.bulk_insert` operation.
fixes #205
Mike Bayer [Sun, 2 Nov 2014 23:33:51 +0000 (18:33 -0500)]
- Indexes and unique constraints are now included in the
:paramref:`.EnvironmentContext.configure.include_object` hook.
Indexes are sent with type ``"index"`` and unique constraints with
type ``"unique_constraint"``.
fixes #203
Mike Bayer [Sun, 2 Nov 2014 17:46:20 +0000 (12:46 -0500)]
- Bound parameters are now resolved as "literal" values within the
SQL expression inside of a CheckConstraint(), when rendering the SQL
as a text string; supported for SQLAlchemy 0.8.0 and forward.
fixes #219
Mike Bayer [Sun, 2 Nov 2014 17:35:47 +0000 (12:35 -0500)]
- Added a workaround for SQLAlchemy issue #3023 (fixed in 0.9.5) where
a column that's part of an explicit PrimaryKeyConstraint would not
have its "nullable" flag set to False, thus producing a false
autogenerate. Also added a related correction to MySQL which will
correct for MySQL's implicit server default of '0' when a NULL integer
column is turned into a primary key column. fixes #199
Mike Bayer [Sun, 2 Nov 2014 15:34:58 +0000 (10:34 -0500)]
- Repaired issue related to the fix for #208 and others; a composite
foreign key reported by MySQL would cause a KeyError as Alembic
attempted to remove MySQL's implicitly generated indexes from the
autogenerate list.
fixes #240
Mike Bayer [Thu, 30 Oct 2014 01:01:31 +0000 (21:01 -0400)]
- If the "alembic_version" table is present in the target metadata,
autogenerate will skip this also. Pull request courtesy
Dj Gilcrease. fixes #28
- The :paramref:`.EnvironmentContext.configure.version_table`
and :paramref:`.EnvironmentContext.configure.version_table_schema`
arguments are now honored during the autogenerate process, such that
these names will be used as the "skip" names on both the database
reflection and target metadata sides. fixes #77
Mike Bayer [Tue, 21 Oct 2014 17:14:06 +0000 (13:14 -0400)]
- the original rationale for defaulting the user-defined namespace
to "sa." was to force users to deal with making sure their custom
types came from a fixed module somewhere. However, it's not worth
defending this rationale.
The default value of the
:paramref:`.EnvironmentContext.configure.user_module_prefix`
parameter is **no longer the same as the SQLAlchemy prefix**.
When omitted, user-defined types will now use the ``__module__``
attribute of the type class itself when rendering in an
autogenerated module.
Revision files are now written out using the ``'wb'`` modifier to
``open()``, since Mako reads the templates with ``'rb'``, thus preventing
CRs from being doubled up as has been observed on windows. The encoding
of the output now defaults to 'utf-8', which can be configured using
a newly added config file parameter ``output_encoding``.
fixes #234
Mike Bayer [Mon, 20 Oct 2014 17:02:32 +0000 (13:02 -0400)]
- Revision files are now written out using the ``'wb'`` modifier to
``open()``, since Mako reads the templates with ``'rb'``, thus preventing
CRs from being doubled up as has been observed on windows.
fixes #234
Mike Bayer [Fri, 3 Oct 2014 15:12:19 +0000 (11:12 -0400)]
- Added support for use of the :class:`~sqlalchemy.sql.elements.quoted_name`
construct when using the ``schema`` argument within operations. This
allows a name containing a dot to be fully quoted, as well as to
provide configurable quoting on a per-name basis.
fixes #230
Mike Bayer [Sat, 20 Sep 2014 21:00:21 +0000 (17:00 -0400)]
- Added a routine by which the Postgresql Alembic dialect inspects
the server default of INTEGER/BIGINT columns as they are reflected
during autogenerate for the pattern ``nextval(<name>...)`` containing
a potential sequence name, then queries ``pg_catalog`` to see if this
sequence is "owned" by the column being reflected; if so, it assumes
this is a SERIAL or BIGSERIAL column and the server default is
omitted from the column reflection as well as any kind of
server_default comparison or rendering, along with an INFO message
in the logs indicating this has taken place. This allows SERIAL/BIGSERIAL
columns to keep the SEQUENCE from being unnecessarily present within
the autogenerate operation.
fixes #73
Mike Bayer [Sat, 20 Sep 2014 18:30:00 +0000 (14:30 -0400)]
- more tweaks for server defaults re: comparison, test results
- in particular we've changed the server_default for order.amount
to text('0'); SQlite and Postgresql now both report the server
default as '0', whereas previously, when we were emitting '0'
with the quotes in the CREATE TABLE, SQlite reported it as
"'0'" and PG as '0::numeric'.
Mike Bayer [Sat, 20 Sep 2014 17:53:11 +0000 (13:53 -0400)]
- restore _render_server_default_for_compare() to compare.py using
the method previously used in _render_server_default() in render;
these two functions become more specific to compare vs. render now
so are separated out
Mike Bayer [Sun, 14 Sep 2014 19:49:04 +0000 (15:49 -0400)]
- coverage was not working (and needs to be fixed in SQLAlchemy too),
go back to using a "bootstrap" system where we load in pytestplugin/
noseplugin via file importing, plugin/ is not used as a package.
- identify the pytest_sessionstart hook as the best place to do
plugin_base.post_begin() and actually begin importing main modules;
this is where coverage has actually started.
- we're now targeting 1.0.0 as this has to be ported to SQLAlchemy.
- start using .coveragerc
Mike Bayer [Sun, 14 Sep 2014 15:37:50 +0000 (11:37 -0400)]
- move pretty much all of sqlalchemy.testing over for now, as we'd
like to run tests against 0.8 and even late 0.7 versions with the same
capabilities, as well as run parallel testing against all of them.
we need a consistent system to get that all to work, so for now
we have the whole SQLA system shoved into here, not ideal but we have
a very good testing situation for now. Once we target 0.9.4 at the lowest
we should be able to move all this out.
- re-support 0.7, starting at 0.7.6 which is where things mostly work.
All tests, taking into account known skips and fails which are
added here for 0.7, early 0.8s, pass on 0.7.9.