diff --git a/core/command/db/converttype.php b/core/command/db/converttype.php
index 617910b3a9051825584f09a5dc4d9f907323fc29..8d1560b0511b3446c6fce8bce615c14f699173f4 100644
--- a/core/command/db/converttype.php
+++ b/core/command/db/converttype.php
@@ -228,6 +228,8 @@ class ConvertType extends Command {
 	}
 
 	protected function getTables(Connection $db) {
+		$db->getConfiguration()->
+			setFilterSchemaAssetsExpression('/^'.$this->config->getSystemValue('dbtableprefix', 'oc_').'/');
 		return $db->getSchemaManager()->listTableNames();
 	}
 
@@ -264,7 +266,7 @@ class ConvertType extends Command {
 				$this->copyTable($fromDB, $toDB, $table, $input, $output);
 			}
 			if ($input->getArgument('type') === 'pgsql') {
-				$tools = new \OC\DB\PgSqlTools;
+				$tools = new \OC\DB\PgSqlTools($this->config);
 				$tools->resynchronizeDatabaseSequences($toDB);
 			}
 			// save new database config
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index 78267094d0ee9989e5594aeb2b61a552e0f631d9..358360d0b462feaded4c2f47431516e2a5aa12a3 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -36,9 +36,7 @@ class MDB2SchemaManager {
 	 * TODO: write more documentation
 	 */
 	public function getDbStructure($file, $mode = MDB2_SCHEMA_DUMP_STRUCTURE) {
-		$sm = $this->conn->getSchemaManager();
-
-		return \OC_DB_MDB2SchemaWriter::saveSchemaToFile($file, $sm);
+		return \OC_DB_MDB2SchemaWriter::saveSchemaToFile($file, $this->conn);
 	}
 
 	/**
@@ -60,19 +58,19 @@ class MDB2SchemaManager {
 	public function getMigrator() {
 		$random = \OC::$server->getSecureRandom()->getMediumStrengthGenerator();
 		$platform = $this->conn->getDatabasePlatform();
+		$config = \OC::$server->getConfig();
 		if ($platform instanceof SqlitePlatform) {
-			$config = \OC::$server->getConfig();
 			return new SQLiteMigrator($this->conn, $random, $config);
 		} else if ($platform instanceof OraclePlatform) {
-			return new OracleMigrator($this->conn, $random);
+			return new OracleMigrator($this->conn, $random, $config);
 		} else if ($platform instanceof MySqlPlatform) {
-			return new MySQLMigrator($this->conn, $random);
+			return new MySQLMigrator($this->conn, $random, $config);
 		} else if ($platform instanceof SQLServerPlatform) {
-			return new MsSqlMigrator($this->conn, $random);
+			return new MsSqlMigrator($this->conn, $random, $config);
 		} else if ($platform instanceof PostgreSqlPlatform) {
-			return new Migrator($this->conn, $random);
+			return new Migrator($this->conn, $random, $config);
 		} else {
-			return new NoCheckMigrator($this->conn, $random);
+			return new NoCheckMigrator($this->conn, $random, $config);
 		}
 	}
 
diff --git a/lib/private/db/mdb2schemawriter.php b/lib/private/db/mdb2schemawriter.php
index a2a62a8147595ec7a4f235b8fb775da77e4743f6..a42cd86ba5434b2a7bcee6f9aa0ae60a2a02c577 100644
--- a/lib/private/db/mdb2schemawriter.php
+++ b/lib/private/db/mdb2schemawriter.php
@@ -10,16 +10,22 @@ class OC_DB_MDB2SchemaWriter {
 
 	/**
 	 * @param string $file
-	 * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
+	 * @param \OC\DB\Connection $conn
 	 * @return bool
 	 */
-	static public function saveSchemaToFile($file, $sm) {
+	static public function saveSchemaToFile($file, \OC\DB\Connection $conn) {
+		$config = \OC::$server->getConfig();
+
 		$xml = new SimpleXMLElement('<database/>');
-		$xml->addChild('name', OC_Config::getValue( "dbname", "owncloud" ));
+		$xml->addChild('name', $config->getSystemValue('dbname', 'owncloud'));
 		$xml->addChild('create', 'true');
 		$xml->addChild('overwrite', 'false');
 		$xml->addChild('charset', 'utf8');
-		foreach ($sm->listTables() as $table) {
+
+		$conn->getConfiguration()->
+			setFilterSchemaAssetsExpression('/^' . $config->getSystemValue('dbtableprefix', 'oc_') . '/');
+
+		foreach ($conn->getSchemaManager()->listTables() as $table) {
 			self::saveTable($table, $xml->addChild('table'));
 		}
 		file_put_contents($file, $xml->asXML());
diff --git a/lib/private/db/migrator.php b/lib/private/db/migrator.php
index 31c648a9b65af831aff7656593d08055cff91611..8ccc02e36a5c19ab63ead458f6b1dfcdb531c527 100644
--- a/lib/private/db/migrator.php
+++ b/lib/private/db/migrator.php
@@ -14,6 +14,7 @@ use \Doctrine\DBAL\Schema\Table;
 use \Doctrine\DBAL\Schema\Schema;
 use \Doctrine\DBAL\Schema\SchemaConfig;
 use \Doctrine\DBAL\Schema\Comparator;
+use OCP\IConfig;
 use OCP\Security\ISecureRandom;
 
 class Migrator {
@@ -28,13 +29,18 @@ class Migrator {
 	 */
 	private $random;
 
+	/** @var IConfig */
+	protected $config;
+
 	/**
 	 * @param \Doctrine\DBAL\Connection $connection
 	 * @param ISecureRandom $random
+	 * @param IConfig $config
 	 */
-	public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random) {
+	public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random, IConfig $config) {
 		$this->connection = $connection;
 		$this->random = $random;
+		$this->config = $config;
 	}
 
 	/**
@@ -70,6 +76,8 @@ class Migrator {
 		 */
 		$tables = $targetSchema->getTables();
 
+		$this->connection->getConfiguration()->
+			setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
 		$existingTables = $this->connection->getSchemaManager()->listTableNames();
 
 		foreach ($tables as $table) {
@@ -153,6 +161,8 @@ class Migrator {
 	}
 
 	protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
+		$connection->getConfiguration()->
+			setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
 		$sourceSchema = $connection->getSchemaManager()->createSchema();
 
 		// remove tables we don't know about
diff --git a/lib/private/db/pgsqltools.php b/lib/private/db/pgsqltools.php
index c3ac140594d224c8c63eb09c3b9cdab3045331a7..f3204d4c7b656681192edcc6f9fe6a8082b8611d 100644
--- a/lib/private/db/pgsqltools.php
+++ b/lib/private/db/pgsqltools.php
@@ -8,11 +8,23 @@
  */
 
 namespace OC\DB;
+use OCP\IConfig;
 
 /**
 * Various PostgreSQL specific helper functions.
 */
 class PgSqlTools {
+
+	/** @var \OCP\IConfig */
+	private $config;
+
+	/**
+	 * @param \OCP\IConfig $config
+	 */
+	public function __construct(IConfig $config) {
+		$this->config = $config;
+	}
+
 	/**
 	* @brief Resynchronizes all sequences of a database after using INSERTs
 	*        without leaving out the auto-incremented column.
@@ -21,6 +33,9 @@ class PgSqlTools {
 	*/
 	public function resynchronizeDatabaseSequences(Connection $conn) {
 		$databaseName = $conn->getDatabase();
+		$conn->getConfiguration()->
+			setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix', 'oc_') . '/');
+
 		foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
 			$sequenceName = $sequence->getName();
 			$sqlInfo = 'SELECT table_schema, table_name, column_name
diff --git a/lib/private/db/sqlitemigrator.php b/lib/private/db/sqlitemigrator.php
index 848e4986571f25f56224bdf9c686982874fbfe72..42b656346453d07ad15c431ed01bbb3db6ec39e0 100644
--- a/lib/private/db/sqlitemigrator.php
+++ b/lib/private/db/sqlitemigrator.php
@@ -10,25 +10,9 @@ namespace OC\DB;
 
 use Doctrine\DBAL\DBALException;
 use Doctrine\DBAL\Schema\Schema;
-use OCP\Security\ISecureRandom;
 
 class SQLiteMigrator extends Migrator {
 
-	/**
-	 * @var \OCP\IConfig
-	 */
-	private $config;
-
-	/**
-	 * @param \Doctrine\DBAL\Connection $connection
-	 * @param ISecureRandom $random
-	 * @param \OCP\IConfig $config
-	 */
-	public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random, \OCP\IConfig $config) {
-		parent::__construct($connection, $random);
-		$this->config = $config;
-	}
-
 	/**
 	 * @param \Doctrine\DBAL\Schema\Schema $targetSchema
 	 * @throws \OC\DB\MigrationException
diff --git a/tests/lib/db/migrator.php b/tests/lib/db/migrator.php
index 1a1d530f1d2a45ff32496870317c88d90ee4c84e..54267740480b202fc2393eb402f5bde6c55e98f0 100644
--- a/tests/lib/db/migrator.php
+++ b/tests/lib/db/migrator.php
@@ -39,7 +39,7 @@ class Migrator extends \Test\TestCase {
 			$this->markTestSkipped('DB migration tests are not supported on MSSQL');
 		}
 		$this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
-		$this->tableName = strtolower($this->getUniqueID('test_'));
+		$this->tableName = strtolower($this->getUniqueID('oc_test_'));
 	}
 
 	protected function tearDown() {