Merge pull request #18253 from nextcloud/bugfix/noid/broken-oracle-install

Pick a shorter name for the transfer ownership table
This commit is contained in:
Roeland Jago Douma 2019-12-10 13:28:33 +01:00 committed by GitHub
commit c9d77b7f7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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\\Helper' => $baseDir . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => $baseDir . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.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\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php',
'OCA\\Files\\Service\\DirectEditingService' => $baseDir . '/../lib/Service/DirectEditingService.php', 'OCA\\Files\\Service\\DirectEditingService' => $baseDir . '/../lib/Service/DirectEditingService.php',
'OCA\\Files\\Service\\OwnershipTransferService' => $baseDir . '/../lib/Service/OwnershipTransferService.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\\Helper' => __DIR__ . '/..' . '/../lib/Helper.php',
'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php', 'OCA\\Files\\Listener\\LegacyLoadAdditionalScriptsAdapter' => __DIR__ . '/..' . '/../lib/Listener/LegacyLoadAdditionalScriptsAdapter.php',
'OCA\\Files\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.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\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php',
'OCA\\Files\\Service\\DirectEditingService' => __DIR__ . '/..' . '/../lib/Service/DirectEditingService.php', 'OCA\\Files\\Service\\DirectEditingService' => __DIR__ . '/..' . '/../lib/Service/DirectEditingService.php',
'OCA\\Files\\Service\\OwnershipTransferService' => __DIR__ . '/..' . '/../lib/Service/OwnershipTransferService.php', 'OCA\\Files\\Service\\OwnershipTransferService' => __DIR__ . '/..' . '/../lib/Service/OwnershipTransferService.php',

View File

@ -31,7 +31,7 @@ use OCP\IDBConnection;
class TransferOwnershipMapper extends QBMapper { class TransferOwnershipMapper extends QBMapper {
public function __construct(IDBConnection $db) { 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 { public function getById(int $id): TransferOwnership {

View File

@ -1,7 +1,5 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/** /**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
* *
@ -24,15 +22,14 @@ declare(strict_types=1);
* *
*/ */
namespace OCA\Files\Migration; namespace OCA\Files\Migration;
use Closure; use Closure;
use OCP\DB\ISchemaWrapper; use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput; use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version11301Date20191113195931 extends SimpleMigrationStep { class Version11301Date20191205150729 extends SimpleMigrationStep {
/** /**
* @param IOutput $output * @param IOutput $output
@ -44,11 +41,12 @@ class Version11301Date20191113195931 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
$table = $schema->createTable('user_transfer_ownership'); $table = $schema->createTable('user_transfer_owner');
$table->addColumn('id', 'integer', [ $table->addColumn('id', 'bigint', [
'autoincrement' => true, 'autoincrement' => true,
'notnull' => true, 'notnull' => true,
'length' => 4, 'length' => 20,
'unsigned' => true,
]); ]);
$table->addColumn('source_user', 'string', [ $table->addColumn('source_user', 'string', [
'notnull' => true, 'notnull' => true,
@ -68,7 +66,12 @@ class Version11301Date20191113195931 extends SimpleMigrationStep {
]); ]);
$table->setPrimaryKey(['id']); $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; return $schema;
} }
} }

View File

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

View File

@ -60,7 +60,7 @@ class MigrationsTest extends \Test\TestCase {
$this->assertEquals('test_oc_migrations', $this->migrationService->getMigrationsTableName()); $this->assertEquals('test_oc_migrations', $this->migrationService->getMigrationsTableName());
} }
public function testExecuteUnknownStep() { public function testExecuteUnknownStep() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Version 20170130180000 is unknown.'); $this->expectExceptionMessage('Version 20170130180000 is unknown.');
@ -68,7 +68,7 @@ class MigrationsTest extends \Test\TestCase {
$this->migrationService->executeStep('20170130180000'); $this->migrationService->executeStep('20170130180000');
} }
public function testUnknownApp() { public function testUnknownApp() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('App not found'); $this->expectExceptionMessage('App not found');
@ -76,7 +76,7 @@ class MigrationsTest extends \Test\TestCase {
$migrationService = new MigrationService('unknown-bloody-app', $this->db); $migrationService = new MigrationService('unknown-bloody-app', $this->db);
} }
public function testExecuteStepWithUnknownClass() { public function testExecuteStepWithUnknownClass() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('Migration step \'X\' is unknown'); $this->expectExceptionMessage('Migration step \'X\' is unknown');
@ -341,7 +341,7 @@ class MigrationsTest extends \Test\TestCase {
$table = $this->createMock(Table::class); $table = $this->createMock(Table::class);
$table->expects($this->any()) $table->expects($this->any())
->method('getName') ->method('getName')
->willReturn(\str_repeat('a', 26)); ->willReturn(\str_repeat('a', 25));
$table->expects($this->once()) $table->expects($this->once())
->method('getColumns') ->method('getColumns')
@ -375,7 +375,7 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
} }
public function testEnsureOracleIdentifierLengthLimitTooLongTableName() { public function testEnsureOracleIdentifierLengthLimitTooLongTableName() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
@ -400,7 +400,7 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
} }
public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithDefault() { public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithDefault() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
@ -453,7 +453,7 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
} }
public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithName() { public function testEnsureOracleIdentifierLengthLimitTooLongPrimaryWithName() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
@ -496,7 +496,7 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
} }
public function testEnsureOracleIdentifierLengthLimitTooLongColumnName() { public function testEnsureOracleIdentifierLengthLimitTooLongColumnName() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
@ -530,7 +530,7 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
} }
public function testEnsureOracleIdentifierLengthLimitTooLongIndexName() { public function testEnsureOracleIdentifierLengthLimitTooLongIndexName() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
@ -567,7 +567,7 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
} }
public function testEnsureOracleIdentifierLengthLimitTooLongForeignKeyName() { public function testEnsureOracleIdentifierLengthLimitTooLongForeignKeyName() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
@ -607,7 +607,7 @@ class MigrationsTest extends \Test\TestCase {
self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]); self::invokePrivate($this->migrationService, 'ensureOracleIdentifierLengthLimit', [$sourceSchema, $schema, 3]);
} }
public function testEnsureOracleIdentifierLengthLimitTooLongSequenceName() { public function testEnsureOracleIdentifierLengthLimitTooLongSequenceName() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);