From: Mike Bayer Date: Thu, 23 Aug 2012 01:43:45 +0000 (-0400) Subject: - changelog + support for remove autoinc X-Git-Tag: rel_0_4_0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ebc3c9cfab406bcd03fb6fad84941dc0df81fdf;p=thirdparty%2Fsqlalchemy%2Falembic.git - changelog + support for remove autoinc --- diff --git a/CHANGES b/CHANGES index d22b4f14..7f37ef89 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,10 @@ didn't work if the server_default was a generated SQL expression. Courtesy Moriyoshi Koizumi. +- [feature] Added support for alteration of MySQL + columns that have AUTO_INCREMENT, as well as enabling + this flag. Courtesy Moriyoshi Koizumi. + 0.3.6 ===== - [feature] Added include_symbol option to diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py index 012aae34..1f04f2a5 100644 --- a/alembic/ddl/mysql.py +++ b/alembic/ddl/mysql.py @@ -98,7 +98,7 @@ def _mysql_colspec(compiler, name, nullable, server_default, type_, compiler.dialect.type_compiler.process(type_), "NULL" if nullable else "NOT NULL" ) - if autoincrement is not None: + if autoincrement: spec += " AUTO_INCREMENT" if server_default != False: spec += " DEFAULT %s" % _render_value(compiler, server_default) diff --git a/tests/test_mysql.py b/tests/test_mysql.py index 28c1fd6a..456aab7c 100644 --- a/tests/test_mysql.py +++ b/tests/test_mysql.py @@ -45,6 +45,15 @@ def test_col_add_autoincrement(): 'ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL AUTO_INCREMENT' ) +def test_col_remove_autoincrement(): + context = op_fixture('mysql') + op.alter_column('t1', 'c1', name="c2", existing_type=Integer, + existing_autoincrement=True, + autoincrement=False) + context.assert_( + 'ALTER TABLE t1 CHANGE c1 c2 INTEGER NULL' + ) + def test_col_nullable(): context = op_fixture('mysql') op.alter_column('t1', 'c1', nullable=False, existing_type=Integer)