Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<name>Photos</name>
<summary>Your memories under your control</summary>
<description>Your memories under your control</description>
<version>3.0.0</version>
<version>3.0.1</version>
<licence>agpl</licence>
<author mail="[email protected]">John Molakvoæ</author>
<namespace>Photos</namespace>
Expand Down
56 changes: 56 additions & 0 deletions lib/Migration/Version30000Date20240417075404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Photos\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Migrate the photosSourceFolder user config to photosSourceFolders
*/
class Version30000Date20240417075404 extends SimpleMigrationStep {
public function __construct(
private IDBConnection $db,
) {
}

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$select = $this->db->getQueryBuilder();
$select->select('userid')
->from('preferences')
->where($select->expr()->eq('appid', $select->expr()->literal('photos')))
->andWhere($select->expr()->eq('configkey', $select->expr()->literal('photosSourceFolders')));

// Remove old entries for users who already have the new one
$delete = $this->db->getQueryBuilder();
$delete->delete('preferences')
->where($delete->expr()->eq('appid', $delete->expr()->literal('photos')))
->andWhere($delete->expr()->eq('configkey', $delete->expr()->literal('photosSourceFolder')))
->andWhere($delete->expr()->in('userid', $delete->createFunction($select->getSQL())))
->executeStatement();

// Update remaining old entries to new ones
$update = $this->db->getQueryBuilder();
$update->update('preferences')
->set('configvalue', $update->func()->concat($update->createNamedParameter('["'), 'configvalue', $update->createNamedParameter('"]')))
->set('configkey', $update->expr()->literal('photosSourceFolders'))
->where($update->expr()->eq('appid', $update->expr()->literal('photos')))
->andWhere($update->expr()->eq('configkey', $update->expr()->literal('photosSourceFolder')))
->executeStatement();
}
}
41 changes: 0 additions & 41 deletions lib/Migration/Version3000Date20240417075404.php

This file was deleted.