summaryrefslogtreecommitdiff
path: root/migrate/changeset/databases/postgres.py
blob: d1d4cc80020450a1d13521356eff3b9ae3b77d66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
   `PostgreSQL`_ database specific implementations of changeset classes.

   .. _`PostgreSQL`: http://www.postgresql.org/
"""
from migrate.changeset import ansisql
from sqlalchemy.databases import postgres as sa_base
#import sqlalchemy as sa


PGSchemaGenerator = sa_base.PGSchemaGenerator


class PGSchemaGeneratorMixin(object):
    """Common code used by the PostgreSQL specific classes."""

    def _do_quote_table_identifier(self, identifier):
        return identifier

    def _do_quote_column_identifier(self, identifier):
        return '"%s"'%identifier


class PGColumnGenerator(PGSchemaGenerator, ansisql.ANSIColumnGenerator,
                        PGSchemaGeneratorMixin):
    """PostgreSQL column generator implementation."""
    pass


class PGColumnDropper(ansisql.ANSIColumnDropper, PGSchemaGeneratorMixin):
    """PostgreSQL column dropper implementation."""
    pass


class PGSchemaChanger(ansisql.ANSISchemaChanger, PGSchemaGeneratorMixin):
    """PostgreSQL schema changer implementation."""
    pass


class PGConstraintGenerator(ansisql.ANSIConstraintGenerator,
                            PGSchemaGeneratorMixin):
    """PostgreSQL constraint generator implementation."""
    pass


class PGConstraintDropper(ansisql.ANSIConstraintDropper,
                          PGSchemaGeneratorMixin):
    """PostgreSQL constaint dropper implementation."""
    pass


class PGDialect(ansisql.ANSIDialect):
    columngenerator = PGColumnGenerator
    columndropper = PGColumnDropper
    schemachanger = PGSchemaChanger
    constraintgenerator = PGConstraintGenerator
    constraintdropper = PGConstraintDropper