diff --git a/apps/files/composer/composer/autoload_classmap.php b/apps/files/composer/composer/autoload_classmap.php index f4d766c8a4..a4a72d59c1 100644 --- a/apps/files/composer/composer/autoload_classmap.php +++ b/apps/files/composer/composer/autoload_classmap.php @@ -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', diff --git a/apps/files/composer/composer/autoload_static.php b/apps/files/composer/composer/autoload_static.php index 4f25b08317..91e29fac48 100644 --- a/apps/files/composer/composer/autoload_static.php +++ b/apps/files/composer/composer/autoload_static.php @@ -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', diff --git a/apps/files/lib/Db/TransferOwnershipMapper.php b/apps/files/lib/Db/TransferOwnershipMapper.php index f9f4e995fe..fe87fc5e48 100644 --- a/apps/files/lib/Db/TransferOwnershipMapper.php +++ b/apps/files/lib/Db/TransferOwnershipMapper.php @@ -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 { diff --git a/apps/files/lib/Migration/Version11301Date20191113195931.php b/apps/files/lib/Migration/Version11301Date20191205150729.php similarity index 81% rename from apps/files/lib/Migration/Version11301Date20191113195931.php rename to apps/files/lib/Migration/Version11301Date20191205150729.php index d5c255bb8a..2ec9bdb471 100644 --- a/apps/files/lib/Migration/Version11301Date20191113195931.php +++ b/apps/files/lib/Migration/Version11301Date20191205150729.php @@ -1,7 +1,5 @@ * @@ -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']); + // 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; } - } diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 71f81d3b1d..9f5b5bfe72 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -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.'); } } diff --git a/tests/lib/DB/MigrationsTest.php b/tests/lib/DB/MigrationsTest.php index 58f775febb..15415a4061 100644 --- a/tests/lib/DB/MigrationsTest.php +++ b/tests/lib/DB/MigrationsTest.php @@ -60,7 +60,7 @@ class MigrationsTest extends \Test\TestCase { $this->assertEquals('test_oc_migrations', $this->migrationService->getMigrationsTableName()); } - + public function testExecuteUnknownStep() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Version 20170130180000 is unknown.'); @@ -68,7 +68,7 @@ class MigrationsTest extends \Test\TestCase { $this->migrationService->executeStep('20170130180000'); } - + public function testUnknownApp() { $this->expectException(\Exception::class); $this->expectExceptionMessage('App not found'); @@ -76,7 +76,7 @@ class MigrationsTest extends \Test\TestCase { $migrationService = new MigrationService('unknown-bloody-app', $this->db); } - + public function testExecuteStepWithUnknownClass() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Migration step \'X\' is unknown'); @@ -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') @@ -375,7 +375,7 @@ class MigrationsTest extends \Test\TestCase { self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } - + public function testEnsureOracleIdentifierLengthLimitTooLongTableName() { $this->expectException(\InvalidArgumentException::class); @@ -400,7 +400,7 @@ class MigrationsTest extends \Test\TestCase { self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } - + public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithDefault() { $this->expectException(\InvalidArgumentException::class); @@ -453,7 +453,7 @@ class MigrationsTest extends \Test\TestCase { self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } - + public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithName() { $this->expectException(\InvalidArgumentException::class); @@ -496,7 +496,7 @@ class MigrationsTest extends \Test\TestCase { self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } - + public function testEnsureOracleIdentifierLengthLimitTooLongColumnName() { $this->expectException(\InvalidArgumentException::class); @@ -530,7 +530,7 @@ class MigrationsTest extends \Test\TestCase { self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } - + public function testEnsureOracleIdentifierLengthLimitTooLongIndexName() { $this->expectException(\InvalidArgumentException::class); @@ -567,7 +567,7 @@ class MigrationsTest extends \Test\TestCase { self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } - + public function testEnsureOracleIdentifierLengthLimitTooLongForeignKeyName() { $this->expectException(\InvalidArgumentException::class); @@ -607,7 +607,7 @@ class MigrationsTest extends \Test\TestCase { self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); } - + public function testEnsureOracleIdentifierLengthLimitTooLongSequenceName() { $this->expectException(\InvalidArgumentException::class);