Skip to content

Commit

Permalink
Drop tables on uninstall
Browse files Browse the repository at this point in the history
fixes #874
  • Loading branch information
marcelklehr committed Apr 8, 2020
1 parent 13928a2 commit aa0963c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ Requirements:
<admin>OCA\Bookmarks\Settings\AdminSettings</admin>
<admin-section>OCA\Bookmarks\Settings\AdminSection</admin-section>
</settings>
<repair-steps>
<uninstall>
<step>OCA\Bookmarks\Migration\UninstallRepairStep</step>
</uninstall>
</repair-steps>
</info>
50 changes: 50 additions & 0 deletions lib/Migration/UninstallRepairStep.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php


namespace OCA\Bookmarks\Migration;


use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class UninstallRepairStep implements IRepairStep {
/**
* @var IDBConnection
*/
private $db;

private $tables = [
'bookmarks',
'bookmarks_tags',
'bookmarks_folders',
'bookmarks_root_folders',
'bookmarks_shared_folders',
'bookmarks_folders_public',
'bookmarks_shares',
'bookmarks_tree',
];

public function __construct(IDBConnection $db) {
$this->db = $db;
}

/**
* Returns the step's name
*/
public function getName() {
return 'Uninstall routine';
}

/**
* @param IOutput $output
*/
public function run(IOutput $output) {
foreach ($this->tables as $table) {
$query = $this->db->prepare("DROP TABLE *PREFIX*$table");
$query->execute();
}
$query = $this->db->prepare("DELETE from *PREFIX*migrations WHERE app = 'bookmarks'");
$query->execute();
}
}

0 comments on commit aa0963c

Please sign in to comment.