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; } }