[3] | 1 | """ |
---|
| 2 | `PostgreSQL`_ database specific implementations of changeset classes. |
---|
| 3 | |
---|
| 4 | .. _`PostgreSQL`: http://www.postgresql.org/ |
---|
| 5 | """ |
---|
| 6 | from migrate.changeset import ansisql |
---|
| 7 | from sqlalchemy.databases import postgres as sa_base |
---|
| 8 | #import sqlalchemy as sa |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | PGSchemaGenerator = sa_base.PGSchemaGenerator |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | class PGSchemaGeneratorMixin(object): |
---|
| 15 | """Common code used by the PostgreSQL specific classes.""" |
---|
| 16 | |
---|
| 17 | def _do_quote_table_identifier(self, identifier): |
---|
| 18 | return identifier |
---|
| 19 | |
---|
| 20 | def _do_quote_column_identifier(self, identifier): |
---|
| 21 | return '"%s"'%identifier |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | class PGColumnGenerator(PGSchemaGenerator, ansisql.ANSIColumnGenerator, |
---|
| 25 | PGSchemaGeneratorMixin): |
---|
| 26 | """PostgreSQL column generator implementation.""" |
---|
| 27 | pass |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | class PGColumnDropper(ansisql.ANSIColumnDropper, PGSchemaGeneratorMixin): |
---|
| 31 | """PostgreSQL column dropper implementation.""" |
---|
| 32 | pass |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | class PGSchemaChanger(ansisql.ANSISchemaChanger, PGSchemaGeneratorMixin): |
---|
| 36 | """PostgreSQL schema changer implementation.""" |
---|
| 37 | pass |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | class PGConstraintGenerator(ansisql.ANSIConstraintGenerator, |
---|
| 41 | PGSchemaGeneratorMixin): |
---|
| 42 | """PostgreSQL constraint generator implementation.""" |
---|
| 43 | pass |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | class PGConstraintDropper(ansisql.ANSIConstraintDropper, |
---|
| 47 | PGSchemaGeneratorMixin): |
---|
| 48 | """PostgreSQL constaint dropper implementation.""" |
---|
| 49 | pass |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | class PGDialect(ansisql.ANSIDialect): |
---|
| 53 | columngenerator = PGColumnGenerator |
---|
| 54 | columndropper = PGColumnDropper |
---|
| 55 | schemachanger = PGSchemaChanger |
---|
| 56 | constraintgenerator = PGConstraintGenerator |
---|
| 57 | constraintdropper = PGConstraintDropper |
---|