diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-27 19:52:24 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-11-27 19:52:24 -0500 |
commit | 198f7067bd44fa31b8d849a433b693187b22b08c (patch) | |
tree | 0141f4be4075c5bfa438c0c8e1306292a1318a03 /alembic/ddl | |
parent | be3ebd2d98955f986c4e101090998c387a5076b8 (diff) | |
download | alembic-198f7067bd44fa31b8d849a433b693187b22b08c.tar.gz |
pg uses DROP NOT NULL, keep this as the default and move
NULL to SQL Server, until we get more data on other DBs
Diffstat (limited to 'alembic/ddl')
-rw-r--r-- | alembic/ddl/base.py | 2 | ||||
-rw-r--r-- | alembic/ddl/mssql.py | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/alembic/ddl/base.py b/alembic/ddl/base.py index 58e3006..5fb5d9c 100644 --- a/alembic/ddl/base.py +++ b/alembic/ddl/base.py @@ -80,7 +80,7 @@ def visit_column_nullable(element, compiler, **kw): return "%s %s %s" % ( alter_table(compiler, element.table_name, element.schema), alter_column(compiler, element.column_name), - "NULL" if element.nullable else "SET NOT NULL" + "DROP NOT NULL" if element.nullable else "SET NOT NULL" ) @compiles(ColumnType) diff --git a/alembic/ddl/mssql.py b/alembic/ddl/mssql.py index 42c2952..3f2b45b 100644 --- a/alembic/ddl/mssql.py +++ b/alembic/ddl/mssql.py @@ -1,5 +1,5 @@ from alembic.ddl.impl import DefaultImpl -from alembic.ddl.base import alter_table, AddColumn, ColumnName, format_table_name, format_column_name +from alembic.ddl.base import alter_table, AddColumn, ColumnName, format_table_name, format_column_name, ColumnNullable, alter_column from sqlalchemy.ext.compiler import compiles class MSSQLImpl(DefaultImpl): @@ -59,6 +59,14 @@ def visit_add_column(element, compiler, **kw): def mssql_add_column(compiler, column, **kw): return "ADD %s" % compiler.get_column_specification(column, **kw) +@compiles(ColumnNullable, 'mssql') +def visit_column_nullable(element, compiler, **kw): + return "%s %s %s" % ( + alter_table(compiler, element.table_name, element.schema), + alter_column(compiler, element.column_name), + "NULL" if element.nullable else "SET NOT NULL" + ) + @compiles(ColumnName, 'mssql') def visit_rename_column(element, compiler, **kw): |