summaryrefslogtreecommitdiff
path: root/alembic/ddl
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-11-28 22:29:43 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-11-28 22:29:43 -0500
commitfb47eda8ea08bc2ece4a2344eb87db115cdcb0d0 (patch)
tree752943d56dd9a0acaee307fdcfeeda2b7eaab6c2 /alembic/ddl
parent48ecd445cfaebad67a143480109586075dcb9ea0 (diff)
downloadalembic-fb47eda8ea08bc2ece4a2344eb87db115cdcb0d0.tar.gz
- add version check for at least 06, tests for 07 in selected
areas - add "requires 07" decorators to test suite - add tests for PG ENUM in offline mode. works in conjunction with the latest 0.7.4 tip of SQLAlchemy, fixes #9. Docs will be needed to illustrate how ENUM should be used. - add support for table before_create and after_create events within op.create_table(). Currently this will do the ENUM thing for PG but will also invoke any other kinds of events that might get configured on the table.
Diffstat (limited to 'alembic/ddl')
-rw-r--r--alembic/ddl/impl.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/alembic/ddl/impl.py b/alembic/ddl/impl.py
index 2c6a666..4159d52 100644
--- a/alembic/ddl/impl.py
+++ b/alembic/ddl/impl.py
@@ -3,6 +3,7 @@ from sqlalchemy.sql.expression import _BindParamClause
from sqlalchemy.ext.compiler import compiles
from sqlalchemy import schema
from alembic.ddl import base
+from alembic import util
from sqlalchemy import types as sqltypes
class ImplMeta(type):
@@ -31,11 +32,13 @@ class DefaultImpl(object):
transactional_ddl = False
- def __init__(self, dialect, connection, as_sql, transactional_ddl, output_buffer):
+ def __init__(self, dialect, connection, as_sql,
+ transactional_ddl, output_buffer):
self.dialect = dialect
self.connection = connection
self.as_sql = as_sql
self.output_buffer = output_buffer
+ self.memo = {}
if transactional_ddl is not None:
self.transactional_ddl = transactional_ddl
@@ -46,6 +49,10 @@ class DefaultImpl(object):
def static_output(self, text):
self.output_buffer.write(text + "\n\n")
+ @property
+ def bind(self):
+ return self.connection
+
def _exec(self, construct, *args, **kw):
if isinstance(construct, basestring):
construct = text(construct)
@@ -123,7 +130,15 @@ class DefaultImpl(object):
new_table_name, schema=schema))
def create_table(self, table):
+ if util.sqla_07:
+ table.dispatch.before_create(table, self.connection,
+ checkfirst=False,
+ _ddl_runner=self)
self._exec(schema.CreateTable(table))
+ if util.sqla_07:
+ table.dispatch.after_create(table, self.connection,
+ checkfirst=False,
+ _ddl_runner=self)
for index in table.indexes:
self._exec(schema.CreateIndex(index))