From 5a5670b7cee2a3eaf2ff25d5a2071e9572bf0c5b Mon Sep 17 00:00:00 2001 From: Fin Clausen Date: Fri, 16 Oct 2026 13:23:20 +0200 Subject: [PATCH] fix: remove unused team favorite creation date Assisted-by: GitHub Copilot GPT-5.6 Sol Signed-off-by: Fin Clausen --- appinfo/info.xml | 2 +- lib/Entity/TeamFavorite.php | 9 --- .../Version360000Date20260922120100.php | 60 +++++++++++++++++++ .../Version360000Date20261016134000.php | 49 +++++++++++++++ .../Repository/TeamFavoriteRepositoryTest.php | 2 +- 5 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 lib/Migration/Version360000Date20260922120100.php create mode 100644 lib/Migration/Version360000Date20261016134000.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 0690ca623..e3c200883 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -12,7 +12,7 @@ Those groups of people can then be used by any other app for sharing purpose. ]]> - 36.0.0-dev.1 + 36.0.0-dev.2 AGPL-3.0-or-later Maxence Lange diff --git a/lib/Entity/TeamFavorite.php b/lib/Entity/TeamFavorite.php index a73667d69..6306e5fe4 100644 --- a/lib/Entity/TeamFavorite.php +++ b/lib/Entity/TeamFavorite.php @@ -9,8 +9,6 @@ namespace OCA\Circles\Entity; -use DateTime; -use DateTimeZone; use OCP\AppFramework\ORM\Attribute\Column; use OCP\AppFramework\ORM\Attribute\Entity as EntityAttribute; use OCP\AppFramework\ORM\Attribute\Id; @@ -30,11 +28,4 @@ final class TeamFavorite { #[Column(name: 'position', type: ColumnType::Integer)] public int $position = 0; - - #[Column(name: 'created', type: ColumnType::Datetime)] - public DateTime $created; - - public function __construct() { - $this->created = new DateTime('now', new DateTimeZone('UTC')); - } } diff --git a/lib/Migration/Version360000Date20260922120100.php b/lib/Migration/Version360000Date20260922120100.php new file mode 100644 index 000000000..89ccc42b4 --- /dev/null +++ b/lib/Migration/Version360000Date20260922120100.php @@ -0,0 +1,60 @@ +hasTable('circles_team_favorites')) { + $table = $schema->createTable('circles_team_favorites'); + $table->addColumn('id', ColumnType::Integer, [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 8, + 'unsigned' => true, + ]); + $table->addColumn('user_id', ColumnType::String, [ + 'length' => 255, + 'notnull' => true, + ]); + $table->addColumn('circle_id', ColumnType::String, [ + 'length' => 32, + 'notnull' => true, + ]); + $table->addColumn('position', ColumnType::Integer, [ + 'notnull' => true, + 'unsigned' => true, + ]); + + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['user_id', 'circle_id']); + $table->addIndex(['user_id', 'position']); + $table->addIndex(['circle_id']); + } + + return $schema; + } +} diff --git a/lib/Migration/Version360000Date20261016134000.php b/lib/Migration/Version360000Date20261016134000.php new file mode 100644 index 000000000..606c8f35d --- /dev/null +++ b/lib/Migration/Version360000Date20261016134000.php @@ -0,0 +1,49 @@ +hasTable('circles_team_favorites')) { + return null; + } + + $table = $schema->getTable('circles_team_favorites'); + if ($table->hasColumn('created')) { + $table->dropColumn('created'); + } + + $hasCircleIndex = false; + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['circle_id']) { + $hasCircleIndex = true; + break; + } + } + if (!$hasCircleIndex) { + $table->addIndex(['circle_id']); + } + + return $schema; + } +} diff --git a/tests/unit/lib/Repository/TeamFavoriteRepositoryTest.php b/tests/unit/lib/Repository/TeamFavoriteRepositoryTest.php index 3a184dac8..f4580fd4f 100644 --- a/tests/unit/lib/Repository/TeamFavoriteRepositoryTest.php +++ b/tests/unit/lib/Repository/TeamFavoriteRepositoryTest.php @@ -118,7 +118,7 @@ private function member(string $circleId, string $singleId, string $userId, int */ private function rows(): array { $query = $this->db->getQueryBuilder(); - $query->select('id', 'circle_id', 'created')->from('circles_team_favorites') + $query->select('id', 'circle_id')->from('circles_team_favorites') ->where($query->expr()->eq('user_id', $query->createNamedParameter($this->userId))) ->orderBy('id'); $result = $query->executeQuery();