93 lines
2.2 KiB
PHP
93 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 F7cloud / F7cloud GmbH and F7cloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\Mail\Migration;
|
|
|
|
use Closure;
|
|
use OCP\DB\ISchemaWrapper;
|
|
use OCP\DB\Types;
|
|
use OCP\Migration\IOutput;
|
|
use OCP\Migration\SimpleMigrationStep;
|
|
use Override;
|
|
|
|
/**
|
|
* Create mail_mailbox_shares table for folder sharing (shared-with-me and subfolders).
|
|
*
|
|
* @codeCoverageIgnore
|
|
*/
|
|
class Version5007Date20260204120000 extends SimpleMigrationStep {
|
|
|
|
#[Override]
|
|
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
|
$schema = $schemaClosure();
|
|
if ($schema->hasTable('mail_mailbox_shares')) {
|
|
return null;
|
|
}
|
|
|
|
$table = $schema->createTable('mail_mailbox_shares');
|
|
|
|
$table->addColumn('id', Types::INTEGER, [
|
|
'autoincrement' => true,
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('owner_user_id', Types::STRING, [
|
|
'notnull' => true,
|
|
'length' => 64,
|
|
]);
|
|
$table->addColumn('account_id', Types::INTEGER, [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('mailbox_id', Types::INTEGER, [
|
|
'notnull' => true,
|
|
]);
|
|
$table->addColumn('share_type', Types::STRING, [
|
|
'notnull' => true,
|
|
'length' => 64,
|
|
]);
|
|
$table->addColumn('share_with', Types::STRING, [
|
|
'notnull' => true,
|
|
'length' => 64,
|
|
]);
|
|
$table->addColumn('permission', Types::STRING, [
|
|
'notnull' => true,
|
|
'length' => 32,
|
|
]);
|
|
$table->addColumn('created_at', Types::INTEGER, [
|
|
'notnull' => true,
|
|
'default' => 0,
|
|
]);
|
|
|
|
$table->setPrimaryKey(['id']);
|
|
$table->addUniqueIndex(
|
|
['owner_user_id', 'account_id', 'mailbox_id', 'share_type', 'share_with'],
|
|
'mail_mailbox_shares_owner_acc_mb_sw'
|
|
);
|
|
$table->addIndex(['share_with', 'share_type'], 'mail_mailbox_shares_share_with_type');
|
|
|
|
if ($schema->hasTable('mail_mailboxes')) {
|
|
$table->addForeignKeyConstraint(
|
|
$schema->getTable('mail_mailboxes'),
|
|
['mailbox_id'],
|
|
['id'],
|
|
['onDelete' => 'CASCADE']
|
|
);
|
|
}
|
|
if ($schema->hasTable('mail_accounts')) {
|
|
$table->addForeignKeyConstraint(
|
|
$schema->getTable('mail_accounts'),
|
|
['account_id'],
|
|
['id'],
|
|
['onDelete' => 'CASCADE']
|
|
);
|
|
}
|
|
|
|
return $schema;
|
|
}
|
|
}
|