Pick a shorter name for the transfer ownership table

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Joas Schilling 2019-12-05 14:38:28 +01:00 committed by Roeland Jago Douma
parent b78a141b0b
commit 059968e1c7
No known key found for this signature in database
GPG Key ID: F941078878347C0C
6 changed files with 27 additions and 24 deletions

View File

@ -45,7 +45,7 @@ return array(
'OCA\\Files\\Helper' => $baseDir . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php',
'OCA\\Files\\Migration\\Version11301Date20191113195931' => $baseDir . '/../lib/Migration/Version11301Date20191113195931.php',
'OCA\\Files\\Migration\\Version11301Date20191205150729' => $baseDir . '/../lib/Migration/Version11301Date20191205150729.php',
'OCA\\Files\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
'OCA\\Files\\Service\\DirectEditingService' => $baseDir . '/../lib/Service/DirectEditingService.php',
'OCA\\Files\\Service\\OwnershipTransferService' => $baseDir . '/../lib/Service/OwnershipTransferService.php',

View File

@ -60,7 +60,7 @@ class ComposerStaticInitFiles
'OCA\\Files\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php',
'OCA\\Files\\Migration\\Version11301Date20191113195931' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191113195931.php',
'OCA\\Files\\Migration\\Version11301Date20191205150729' => __DIR__ . '/..' . '/../lib/Migration/Version11301Date20191205150729.php',
'OCA\\Files\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
'OCA\\Files\\Service\\DirectEditingService' => __DIR__ . '/..' . '/../lib/Service/DirectEditingService.php',
'OCA\\Files\\Service\\OwnershipTransferService' => __DIR__ . '/..' . '/../lib/Service/OwnershipTransferService.php',

View File

@ -31,7 +31,7 @@ use OCP\IDBConnection;
class TransferOwnershipMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'user_transfer_ownership', TransferOwnership::class);
parent::__construct($db, 'user_transfer_owner', TransferOwnership::class);
}
public function getById(int $id): TransferOwnership {

View File

@ -1,7 +1,5 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
@ -24,15 +22,14 @@ declare(strict_types=1);
*
*/
namespace OCA\Files\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version11301Date20191113195931 extends SimpleMigrationStep {
class Version11301Date20191205150729 extends SimpleMigrationStep {
/**
* @param IOutput $output
@ -44,11 +41,12 @@ class Version11301Date20191113195931 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->createTable('user_transfer_ownership');
$table->addColumn('id', 'integer', [
$table = $schema->createTable('user_transfer_owner');
$table->addColumn('id', 'bigint', [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
'length' => 20,
'unsigned' => true,
]);
$table->addColumn('source_user', 'string', [
'notnull' => true,
@ -68,7 +66,12 @@ class Version11301Date20191113195931 extends SimpleMigrationStep {
]);
$table->setPrimaryKey(['id']);
return $schema;
// Quite radical, we just assume no one updates cross beta with a pending request.
// Do not try this at home
if ($schema->hasTable('user_transfer_ownership')) {
$schema->dropTable('user_transfer_ownership');
}
return $schema;
}
}

View File

@ -550,7 +550,7 @@ class MigrationService {
if (!$isUsingDefaultName && \strlen($indexName) > 30) {
throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.');
}
if ($isUsingDefaultName && \strlen($table->getName()) - $prefixLength > 23) {
if ($isUsingDefaultName && \strlen($table->getName()) - $prefixLength >= 23) {
throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.');
}
}

View File

@ -341,7 +341,7 @@ class MigrationsTest extends \Test\TestCase {
$table = $this->createMock(Table::class);
$table->expects($this->any())
->method('getName')
->willReturn(\str_repeat('a', 26));
->willReturn(\str_repeat('a', 25));
$table->expects($this->once())
->method('getColumns')