2009-01-25 12:52:33 +00:00
|
|
|
"""
|
|
|
|
`PostgreSQL`_ database specific implementations of changeset classes.
|
|
|
|
|
|
|
|
.. _`PostgreSQL`: http://www.postgresql.org/
|
|
|
|
"""
|
2008-02-06 18:39:07 +00:00
|
|
|
from migrate.changeset import ansisql
|
|
|
|
from sqlalchemy.databases import postgres as sa_base
|
|
|
|
#import sqlalchemy as sa
|
|
|
|
|
2009-01-25 12:52:33 +00:00
|
|
|
|
2008-02-06 18:39:07 +00:00
|
|
|
PGSchemaGenerator = sa_base.PGSchemaGenerator
|
|
|
|
|
2009-01-25 12:52:33 +00:00
|
|
|
|
2008-12-02 15:25:12 +00:00
|
|
|
class PGSchemaGeneratorMixin(object):
|
2009-01-25 12:52:33 +00:00
|
|
|
"""Common code used by the PostgreSQL specific classes."""
|
2008-11-26 22:05:19 +00:00
|
|
|
|
2008-12-02 18:27:16 +00:00
|
|
|
def _do_quote_table_identifier(self, identifier):
|
|
|
|
return identifier
|
2009-01-25 12:52:33 +00:00
|
|
|
|
2008-12-02 18:27:16 +00:00
|
|
|
def _do_quote_column_identifier(self, identifier):
|
|
|
|
return '"%s"'%identifier
|
2008-11-26 22:05:19 +00:00
|
|
|
|
2009-01-25 12:52:33 +00:00
|
|
|
|
|
|
|
class PGColumnGenerator(PGSchemaGenerator, ansisql.ANSIColumnGenerator,
|
|
|
|
PGSchemaGeneratorMixin):
|
|
|
|
"""PostgreSQL column generator implementation."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2008-12-02 15:25:12 +00:00
|
|
|
class PGColumnDropper(ansisql.ANSIColumnDropper, PGSchemaGeneratorMixin):
|
2009-01-25 12:52:33 +00:00
|
|
|
"""PostgreSQL column dropper implementation."""
|
|
|
|
pass
|
|
|
|
|
2008-11-26 22:05:19 +00:00
|
|
|
|
2008-12-02 15:25:12 +00:00
|
|
|
class PGSchemaChanger(ansisql.ANSISchemaChanger, PGSchemaGeneratorMixin):
|
2009-01-25 12:52:33 +00:00
|
|
|
"""PostgreSQL schema changer implementation."""
|
|
|
|
pass
|
2008-12-02 15:25:12 +00:00
|
|
|
|
2008-12-02 15:41:25 +00:00
|
|
|
|
2009-01-25 12:52:33 +00:00
|
|
|
class PGConstraintGenerator(ansisql.ANSIConstraintGenerator,
|
|
|
|
PGSchemaGeneratorMixin):
|
|
|
|
"""PostgreSQL constraint generator implementation."""
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class PGConstraintDropper(ansisql.ANSIConstraintDropper,
|
|
|
|
PGSchemaGeneratorMixin):
|
|
|
|
"""PostgreSQL constaint dropper implementation."""
|
|
|
|
pass
|
|
|
|
|
2008-02-06 18:39:07 +00:00
|
|
|
|
|
|
|
class PGDialect(ansisql.ANSIDialect):
|
|
|
|
columngenerator = PGColumnGenerator
|
|
|
|
columndropper = PGColumnDropper
|
|
|
|
schemachanger = PGSchemaChanger
|
|
|
|
constraintgenerator = PGConstraintGenerator
|
|
|
|
constraintdropper = PGConstraintDropper
|