summaryrefslogtreecommitdiffstats
path: root/lib/db.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/db.php')
-rw-r--r--lib/db.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/db.php b/lib/db.php
index a0fb6c385d8..a7b7ae75da0 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -483,6 +483,33 @@ class OC_DB {
}
/**
+ * @breif replaces the owncloud tables with a new set
+ * @param $file string path to the MDB2 xml db export file
+ */
+ public static function replaceDB( $file ){
+
+ $apps = OC_App::getAllApps();
+
+ // Delete the old tables
+ self::removeDBStructure( OC::$SERVERROOT . '/db_structure.xml' );
+
+ foreach($apps as $app){
+ $path = OC::$SERVERROOT.'/apps/'.$app.'/appinfo/database.xml';
+ if(file_exists($path)){
+ self::removeDBStructure( $path );
+ }
+ }
+
+ // Create new tables
+ if( self::createDBFromStructure( $file ) ){
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ /**
* Start a transaction
*/
public static function beginTransaction(){
@@ -586,3 +613,4 @@ class PDOStatementWrapper{
return $this->statement->fetchColumn($colnum);
}
}
+