~stephen-xemacs/mailman/sprint-2012-overview

« back to all changes in this revision

Viewing changes to src/mailman/database/postgresql.py

  • Committer: Barry Warsaw
  • Date: 2012-02-12 15:01:07 UTC
  • Revision ID: barry@list.org-20120212150107-8mljy77gom8ff1oc
 * Schema migrations have been implemented.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
 
28
28
from operator import attrgetter
29
 
from pkg_resources import resource_string
30
29
 
31
30
from mailman.database.base import StormBaseDatabase
32
31
 
35
34
class PostgreSQLDatabase(StormBaseDatabase):
36
35
    """Database class for PostgreSQL."""
37
36
 
 
37
    TAG = 'postgres'
 
38
 
38
39
    def _database_exists(self, store):
39
40
        """See `BaseDatabase`."""
40
41
        table_query = ('SELECT table_name FROM information_schema.tables '
43
44
                          store.execute(table_query))
44
45
        return 'version' in table_names
45
46
 
46
 
    def _get_schema(self):
47
 
        """See `BaseDatabase`."""
48
 
        return resource_string('mailman.database.sql', 'postgres.sql')
49
 
 
50
47
    def _post_reset(self, store):
51
48
        """PostgreSQL-specific test suite cleanup.
52
49
 
53
50
        Reset the <tablename>_id_seq.last_value so that primary key ids
54
51
        restart from zero for new tests.
55
52
        """
 
53
        super(PostgreSQLDatabase, self)._post_reset(store)
56
54
        from mailman.database.model import ModelMeta
57
55
        classes = sorted(ModelMeta._class_registry,
58
56
                         key=attrgetter('__storm_table__'))