diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-10-15 12:24:38 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-10-30 19:16:24 +0300 |
commit | 15867528b25cad3e1262014d0fa4f967a73d64be (patch) | |
tree | 6dd7c46876325acf8aad147b9ef791a73376c102 /lib/Migration | |
parent | fe074001833362fa1eb4d18576131b0678907fb5 (diff) |
Store special mailboxes as preference of the account
… instead of using a fragile autodetection every time we need one of
those. We will still try to auto-detect the mailboxes but the users will
have to option to change the destinations.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Migration')
-rw-r--r-- | lib/Migration/Version1060Date20201015084952.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/Migration/Version1060Date20201015084952.php b/lib/Migration/Version1060Date20201015084952.php new file mode 100644 index 000000000..222ab62e5 --- /dev/null +++ b/lib/Migration/Version1060Date20201015084952.php @@ -0,0 +1,59 @@ +<?php + +declare(strict_types=1); + +namespace OCA\Mail\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version1060Date20201015084952 extends SimpleMigrationStep { + + /** @var IDBConnection */ + protected $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $accountsTable = $schema->getTable('mail_accounts'); + $accountsTable->addColumn('drafts_mailbox_id', 'integer', [ + 'notnull' => false, + 'default' => null, + 'length' => 20, + ]); + $accountsTable->addColumn('sent_mailbox_id', 'integer', [ + 'notnull' => false, + 'default' => null, + 'length' => 20, + ]); + $accountsTable->addColumn('trash_mailbox_id', 'integer', [ + 'notnull' => false, + 'default' => null, + 'length' => 20, + ]); + + return $schema; + } + + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { + // Force a re-sync, so the values are propagated ASAP + $update = $this->connection->getQueryBuilder(); + $update->update('mail_accounts') + ->set('last_mailbox_sync', $update->createNamedParameter(0)); + $update->execute(); + } +} |