-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! fixup! fixup! fixup! Make it possible to mark messages important
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
- Loading branch information
1 parent
8a6f5ba
commit fce904a
Showing
3 changed files
with
173 additions
and
33 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?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 Version1040Date20200422130220 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(); | ||
|
||
$schema->dropTable('mail_messages'); | ||
|
||
return $schema; | ||
} | ||
|
||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { | ||
// Reset locks and sync tokens | ||
$qb1 = $this->connection->getQueryBuilder(); | ||
$updateMailboxes = $qb1->update('mail_mailboxes') | ||
->set('sync_new_lock', $qb1->createNamedParameter(null)) | ||
->set('sync_new_token', $qb1->createNamedParameter(null)) | ||
->set('sync_changed_lock', $qb1->createNamedParameter(null)) | ||
->set('sync_changed_token', $qb1->createNamedParameter(null)) | ||
->set('sync_vanished_lock', $qb1->createNamedParameter(null)) | ||
->set('sync_vanished_token', $qb1->createNamedParameter(null)); | ||
$updateMailboxes->execute(); | ||
|
||
// Clean up some orphaned data | ||
$qb2 = $this->connection->getQueryBuilder(); | ||
$deleteRecipients = $qb2->delete('mail_recipients'); | ||
$deleteRecipients->execute(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\Mail\Migration; | ||
|
||
use Closure; | ||
use OCP\DB\ISchemaWrapper; | ||
use OCP\Migration\IOutput; | ||
use OCP\Migration\SimpleMigrationStep; | ||
|
||
class Version1040Date20200422142920 extends SimpleMigrationStep { | ||
|
||
/** | ||
* @param IOutput $output | ||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
* @param array $options | ||
* | ||
* @return null|ISchemaWrapper | ||
*/ | ||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { | ||
/** @var ISchemaWrapper $schema */ | ||
$schema = $schemaClosure(); | ||
|
||
$messagesTable = $schema->createTable('mail_messages'); | ||
$messagesTable->addColumn('id', 'integer', [ | ||
'autoincrement' => true, | ||
'notnull' => true, | ||
'length' => 20, | ||
]); | ||
$messagesTable->addColumn('uid', 'integer', [ | ||
'notnull' => true, | ||
'length' => 4, | ||
]); | ||
$messagesTable->addColumn('message_id', 'string', [ | ||
'notnull' => false, | ||
'length' => 255, | ||
]); | ||
$messagesTable->addColumn('mailbox_id', 'integer', [ | ||
'notnull' => true, | ||
'length' => 20, | ||
]); | ||
$messagesTable->addColumn('subject', 'string', [ | ||
'notnull' => true, | ||
'length' => 255, | ||
'default' => '', | ||
]); | ||
$messagesTable->addColumn('sent_at', 'integer', [ | ||
'notnull' => true, | ||
'length' => 4, | ||
]); | ||
$messagesTable->addColumn('flag_answered', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_deleted', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_draft', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_flagged', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_seen', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_forwarded', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_junk', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_notjunk', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('flag_attachments', 'boolean', [ | ||
'notnull' => false, | ||
]); | ||
$messagesTable->addColumn('flag_important', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('structure_analyzed', 'boolean', [ | ||
'notnull' => true, | ||
'default' => false, | ||
]); | ||
$messagesTable->addColumn('preview_text', 'string', [ | ||
'notnull' => false, | ||
'length' => 255, | ||
]); | ||
$messagesTable->addColumn('updated_at', 'integer', [ | ||
'notnull' => false, | ||
'length' => 4, | ||
]); | ||
$messagesTable->setPrimaryKey(['id']); | ||
// We allow each UID just once | ||
$messagesTable->addUniqueIndex( | ||
[ | ||
'uid', | ||
'mailbox_id', | ||
], | ||
'mail_msg_mb_uid_idx' | ||
); | ||
$messagesTable->addIndex(['sent_at'], 'mail_msg_sent_idx'); | ||
|
||
return $schema; | ||
} | ||
|
||
} |