diff --git a/defaultccplugin/trunk/defaultcc/__init__.py b/defaultccplugin/trunk/defaultcc/__init__.py
index 2349764..65ccc70 100644
--- a/defaultccplugin/trunk/defaultcc/__init__.py
+++ b/defaultccplugin/trunk/defaultcc/__init__.py
@@ -1,2 +1,2 @@
 import pkg_resources
-pkg_resources.require('Trac >= 1.0')
+pkg_resources.require('Trac >= 0.12')
diff --git a/defaultccplugin/trunk/defaultcc/admin.py b/defaultccplugin/trunk/defaultcc/admin.py
index 448b417..bb84d28 100644
--- a/defaultccplugin/trunk/defaultcc/admin.py
+++ b/defaultccplugin/trunk/defaultcc/admin.py
@@ -15,7 +15,7 @@ from genshi.core import START
 from genshi.filters import Transformer
 from genshi.filters.transform import INSIDE
 
-from trac.core import Component, implements
+from trac.core import Component, TracError, implements
 from trac.db import Column, DatabaseManager, Index, Table
 from trac.env import IEnvironmentSetupParticipant
 from trac.resource import ResourceNotFound
@@ -44,26 +44,38 @@ class DefaultCCAdmin(Component):
     # IEnvironmentSetupParticipant methods
 
     def environment_created(self):
-        self._upgrade_db()
+        @self.env.with_transaction()
+        def tx(db):
+            self._upgrade_db(db)
 
     def environment_needs_upgrade(self, db):
-        try:
-            self.env.db_query("SELECT COUNT(*) FROM component_default_cc")
-        except self.env.db_exc.OperationalError:  # No such table
-            return True
-        else:
-            return False
+        return 'component_default_cc' not in self._get_tables(db)
 
     def upgrade_environment(self, db):
-        self._upgrade_db()
+        self._upgrade_db(db)
 
-    def _upgrade_db(self):
+    def _upgrade_db(self, db):
         db_backend = DatabaseManager(self.env)._get_connector()[0]
-        with self.env.db_transaction as db:
-            cursor = db.cursor()
-            for table in self.SCHEMA:
-                for stmt in db_backend.to_sql(table):
-                    cursor.execute(stmt)
+        cursor = db.cursor()
+        for table in self.SCHEMA:
+            for stmt in db_backend.to_sql(table):
+                cursor.execute(stmt)
+
+    def _get_tables(self, db):
+        dburi = self.config.get('trac', 'database')
+        cursor = db.cursor()
+        if dburi.startswith('sqlite:'):
+            query = "SELECT name FROM sqlite_master" \
+                    " WHERE type='table' AND NOT name='sqlite_sequence'"
+        elif dburi.startswith('postgres:'):
+            query = "SELECT tablename FROM pg_tables" \
+                    " WHERE schemaname = ANY (current_schemas(false))"
+        elif dburi.startswith('mysql:'):
+            query = "SHOW TABLES"
+        else:
+            raise TracError('Unsupported %s database' % dburi.split(':')[0])
+        cursor.execute(query)
+        return sorted(row[0] for row in cursor)
 
     # IRequestFilter methods
 
diff --git a/defaultccplugin/trunk/defaultcc/model.py b/defaultccplugin/trunk/defaultcc/model.py
index c11b5be..097d0dd 100644
--- a/defaultccplugin/trunk/defaultcc/model.py
+++ b/defaultccplugin/trunk/defaultcc/model.py
@@ -23,34 +23,43 @@ class DefaultCC(object):
         self.name = name
         self.cc = None
         if name:
-            for cc, in self.env.db_query("""
-                    SELECT cc FROM component_default_cc WHERE name=%s
-                    """, (name,)):
+            db = self.env.get_read_db()
+            cursor = db.cursor()
+            cursor.execute("""
+                SELECT cc FROM component_default_cc WHERE name=%s
+                """, (name,))
+            for cc, in cursor:
                 self.cc = cc or None
 
     def delete(self, db=None):
         self.log.info("Deleting component %s's default CC" % self.name)
-        self.env.db_transaction("""
-            DELETE FROM component_default_cc WHERE name=%s
-            """, (self.name,))
+        @self.env.with_trasaction()
+        def tx(db):
+            cursor = db.cursor()
+            cursor.execute("""
+                DELETE FROM component_default_cc WHERE name=%s
+                """, (self.name,))
 
     def insert(self, db=None):
         assert self.name, "Cannot create default CC for a component" \
                           " without a name"
 
         self.log.debug("Creating %s's default CC" % self.name)
-        self.env.db_transaction("""
-            INSERT INTO component_default_cc (name,cc) VALUES (%s,%s)
-            """, (self.name, _fixup_cc_list(self.cc)))
+        @self.env.with_trasaction()
+        def tx(db):
+            cursor = db.cursor()
+            cursor.execute("""
+                INSERT INTO component_default_cc (name,cc) VALUES (%s,%s)
+                """, (self.name, _fixup_cc_list(self.cc)))
 
     @classmethod
     def select(cls, env, db=None):
-        res = {}
-        for name, cc in env.db_query("""
+        db = env.get_read_db()
+        cursor = db.cursor()
+        cursor.execute("""
                 SELECT name,cc FROM component_default_cc ORDER BY name
-                """):
-            res[name] = cc
-        return res
+                """)
+        return dict((name, cc) for name, cc in cursor)
 
 
 def _fixup_cc_list(cc_value):
