From 760c3e3ae2a97eecd5b41f9e2c97564c38af215f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 28 Nov 2011 00:58:00 -0500 Subject: initial MySQL support, good thing we tried this before releasing --- alembic/ddl/base.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'alembic/ddl/base.py') diff --git a/alembic/ddl/base.py b/alembic/ddl/base.py index 5fb5d9c..a3e6eff 100644 --- a/alembic/ddl/base.py +++ b/alembic/ddl/base.py @@ -1,7 +1,7 @@ import functools from sqlalchemy.ext.compiler import compiles from sqlalchemy.schema import DDLElement - +from sqlalchemy import types as sqltypes class AlterTable(DDLElement): """Represent an ALTER TABLE statement. @@ -19,28 +19,37 @@ class RenameTable(AlterTable): self.new_table_name = new_table_name class AlterColumn(AlterTable): - def __init__(self, name, column_name, schema=None): + def __init__(self, name, column_name, schema=None, + existing_type=None, + existing_nullable=None, + existing_server_default=None): super(AlterColumn, self).__init__(name, schema=schema) self.column_name = column_name + self.existing_type=sqltypes.to_instance(existing_type) \ + if existing_type is not None else None + self.existing_nullable=existing_nullable + self.existing_server_default=existing_server_default class ColumnNullable(AlterColumn): - def __init__(self, name, column_name, nullable, schema=None): - super(ColumnNullable, self).__init__(name, column_name, schema=schema) + def __init__(self, name, column_name, nullable, **kw): + super(ColumnNullable, self).__init__(name, column_name, + **kw) self.nullable = nullable class ColumnType(AlterColumn): - def __init__(self, name, column_name, type_, schema=None): - super(ColumnType, self).__init__(name, column_name, schema=schema) - self.type_ = type_ + def __init__(self, name, column_name, type_, **kw): + super(ColumnType, self).__init__(name, column_name, + **kw) + self.type_ = sqltypes.to_instance(type_) class ColumnName(AlterColumn): - def __init__(self, name, column_name, newname, schema=None): - super(ColumnName, self).__init__(name, column_name, schema=schema) + def __init__(self, name, column_name, newname, **kw): + super(ColumnName, self).__init__(name, column_name, **kw) self.newname = newname class ColumnDefault(AlterColumn): - def __init__(self, name, column_name, default, schema=None): - super(ColumnDefault, self).__init__(name, column_name, schema=schema) + def __init__(self, name, column_name, default, **kw): + super(ColumnDefault, self).__init__(name, column_name, **kw) self.default = default class AddColumn(AlterTable): -- cgit v1.2.1