diff --git a/appinfo/database.xml b/appinfo/database.xml
index 6cbbe952d..9c93a9e35 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -317,6 +317,13 @@
true
8
+
+ last_modified
+ integer
+
+ false
+ true
+
deck_labels_board_id_index
diff --git a/lib/Db/Label.php b/lib/Db/Label.php
index 47a3bc221..deeba32f9 100644
--- a/lib/Db/Label.php
+++ b/lib/Db/Label.php
@@ -29,10 +29,12 @@ class Label extends RelationalEntity {
protected $color;
protected $boardId;
protected $cardId;
+ protected $lastModified;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('boardId', 'integer');
$this->addType('cardId', 'integer');
+ $this->addType('lastModified', 'integer');
}
}
diff --git a/lib/Db/LabelMapper.php b/lib/Db/LabelMapper.php
index ec0e653d5..f147d02e3 100644
--- a/lib/Db/LabelMapper.php
+++ b/lib/Db/LabelMapper.php
@@ -23,6 +23,7 @@
namespace OCA\Deck\Db;
+use OCP\AppFramework\Db\Entity;
use OCP\IDBConnection;
@@ -54,6 +55,19 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
+ public function insert(Entity $entity) {
+ $entity->setLastModified(time());
+ return parent::insert($entity);
+ }
+
+ public function update(Entity $entity, $updateModified = true) {
+ if ($updateModified) {
+ $entity->setLastModified(time());
+ }
+ return parent::update($entity);
+ }
+
+
public function getAssignedLabelsForBoard($boardId) {
$labels = $this->findAssignedLabelsForBoard($boardId);
$result = array();
diff --git a/tests/unit/Db/LabelTest.php b/tests/unit/Db/LabelTest.php
index 15c67f216..f74c74e1d 100644
--- a/tests/unit/Db/LabelTest.php
+++ b/tests/unit/Db/LabelTest.php
@@ -41,6 +41,7 @@ class LabelTest extends TestCase {
'title' => 'My Label',
'boardId' => 123,
'cardId' => null,
+ 'lastModified' => null,
'color' => '000000'
], $label->jsonSerialize());
@@ -53,10 +54,11 @@ class LabelTest extends TestCase {
'title' => 'My Label',
'boardId' => null,
'cardId' => 123,
+ 'lastModified' => null,
'color' => '000000'
], $label->jsonSerialize());
}
-}
\ No newline at end of file
+}