1<?php 2 3declare(strict_types=1); 4 5/** 6 * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> 7 * 8 * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> 9 * 10 * @license GNU AGPL version 3 or any later version 11 * 12 * This program is free software: you can redistribute it and/or modify 13 * it under the terms of the GNU Affero General Public License as 14 * published by the Free Software Foundation, either version 3 of the 15 * License, or (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU Affero General Public License for more details. 21 * 22 * You should have received a copy of the GNU Affero General Public License 23 * along with this program. If not, see <http://www.gnu.org/licenses/>. 24 */ 25 26namespace OCA\Mail\Migration; 27 28use Closure; 29use OCP\DB\ISchemaWrapper; 30use OCP\IDBConnection; 31use OCP\Migration\SimpleMigrationStep; 32use OCP\Migration\IOutput; 33 34class Version0161Date20190902114635 extends SimpleMigrationStep { 35 36 /** @var IDBConnection */ 37 protected $connection; 38 39 public function __construct(IDBConnection $connection) { 40 $this->connection = $connection; 41 } 42 43 /** 44 * @param IOutput $output 45 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` 46 * @param array $options 47 * 48 * @return null|ISchemaWrapper 49 */ 50 public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { 51 /** @var ISchemaWrapper $schema */ 52 $schema = $schemaClosure(); 53 54 $mailboxTable = $schema->getTable('mail_mailboxes'); 55 $mailboxTable->addColumn('special_use', 'string', [ 56 'length' => 255, 57 'default' => '[]', 58 ]); 59 60 return $schema; 61 } 62 63 public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { 64 // Force a re-sync 65 $update = $this->connection->getQueryBuilder(); 66 $update->update('mail_accounts') 67 ->set('last_mailbox_sync', $update->createNamedParameter(0)); 68 69 $update->execute(); 70 } 71} 72