diff --git a/internal/sqladapter/database.go b/internal/sqladapter/database.go
index 830c5a75a08b7ec7cd0c991bb055987b039e84a3..4a9ec70d6be2fafd5d34d7c650ed1466d63ea038 100644
--- a/internal/sqladapter/database.go
+++ b/internal/sqladapter/database.go
@@ -34,9 +34,9 @@ type Database interface {
 type BaseDatabase struct {
 	partial PartialDatabase
 	sess    *sqlx.DB
+	tx      *sqltx.Tx
 
 	connURL          db.ConnectionURL
-	tx               *sqltx.Tx
 	schema           *schema.DatabaseSchema
 	cachedStatements *cache.Cache
 	collections      map[string]db.Collection
@@ -250,6 +250,9 @@ func (d *BaseDatabase) Builder() db.QueryBuilder {
 
 // Driver returns the underlying *sqlx.DB instance.
 func (d *BaseDatabase) Driver() interface{} {
+	if d.tx != nil {
+		return d.tx.Tx
+	}
 	return d.sess
 }
 
diff --git a/internal/sqlutil/tx/tx.go b/internal/sqlutil/tx/tx.go
index 18ebbf3c937be3a329cc778c26aa99d471539c7d..ac45498a440f70ca228ec62bc0c0c27a31131b0e 100644
--- a/internal/sqlutil/tx/tx.go
+++ b/internal/sqlutil/tx/tx.go
@@ -23,8 +23,14 @@ package sqltx
 
 import (
 	"github.com/jmoiron/sqlx"
+	"upper.io/db"
 )
 
+type Database struct {
+	db.Database
+	*Tx
+}
+
 type Tx struct {
 	*sqlx.Tx
 	done bool
diff --git a/postgresql/database.go b/postgresql/database.go
index 6c112a03d5ff41b0e42b3780faacd7e97d6bbfcf..2a195d707595b9530730711d2f6ad5d7e7e80f11 100644
--- a/postgresql/database.go
+++ b/postgresql/database.go
@@ -30,6 +30,7 @@ import (
 	"upper.io/builder/sqlgen"
 	"upper.io/db"
 	"upper.io/db/internal/sqladapter"
+	"upper.io/db/internal/sqlutil/tx"
 )
 
 type database struct {
@@ -174,7 +175,7 @@ func (d *database) Transaction() (db.Tx, error) {
 
 	clone.BindTx(sqlTx)
 
-	return &tx{Tx: clone.Tx(), database: clone}, nil
+	return &sqltx.Database{Database: clone, Tx: clone.Tx()}, nil
 }
 
 // PopulateSchema looks up for the table info in the database and populates its
diff --git a/postgresql/tx.go b/postgresql/tx.go
deleted file mode 100644
index 5a91a828958955b250293d4aa705be74ff69b0ed..0000000000000000000000000000000000000000
--- a/postgresql/tx.go
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2012-2015 The upper.io/db authors. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-package postgresql
-
-import (
-	"upper.io/db"
-	"upper.io/db/internal/sqlutil/tx"
-)
-
-type tx struct {
-	*sqltx.Tx
-	*database
-}
-
-var _ = db.Tx(&tx{})
-
-// Driver returns the current transaction session.
-func (t *tx) Driver() interface{} {
-	if t != nil && t.Tx != nil {
-		return t.Tx.Tx
-	}
-	return nil
-}
-
-// Commit commits the current transaction.
-func (t *tx) Commit() error {
-	if err := t.Tx.Commit(); err != nil {
-		return err
-	}
-	return nil
-}
-
-// Rollback discards the current transaction.
-func (t *tx) Rollback() error {
-	if err := t.Tx.Rollback(); err != nil {
-		return err
-	}
-	return nil
-}