Merge pull request #10213 from nextcloud/bugfix/noid/shorten-resource-table-names-to-allow-install-on-oracle

Shorten resource table names to allow install on oracle again
This commit is contained in:
Morris Jobke 2018-07-12 12:30:52 +02:00 committed by GitHub
commit 09d5b61c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 34 additions and 37 deletions

View File

@ -45,7 +45,7 @@ class CleanupInvitationTokenJob extends TimedJob {
public function run($argument) {
$query = $this->db->getQueryBuilder();
$query->delete('calendar_invitation_tokens')
$query->delete('calendar_invitations')
->where($query->expr()->lt('expiration',
$query->createNamedParameter($this->timeFactory->getTime())))
->execute();

View File

@ -72,9 +72,9 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
$this->roomManager = $roomManager;
$this->db = $dbConnection;
$this->calDavBackend = $calDavBackend;
$this->resourceDbTable = 'calendar_resources_cache';
$this->resourceDbTable = 'calendar_resources';
$this->resourcePrincipalUri = 'principals/calendar-resources';
$this->roomDbTable = 'calendar_rooms_cache';
$this->roomDbTable = 'calendar_rooms';
$this->roomPrincipalUri = 'principals/calendar-rooms';
// run once an hour

View File

@ -68,7 +68,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
$this->groupManager = $groupManager;
$this->logger = $logger;
$this->principalPrefix = $principalPrefix;
$this->dbTableName = 'calendar_' . $dbPrefix . '_cache';
$this->dbTableName = 'calendar_' . $dbPrefix;
}
/**

View File

@ -536,7 +536,7 @@ class IMipPlugin extends SabreIMipPlugin {
$uid = $vevent->{'UID'};
$query = $this->db->getQueryBuilder();
$query->insert('calendar_invitation_tokens')
$query->insert('calendar_invitations')
->values([
'token' => $query->createNamedParameter($token),
'attendee' => $query->createNamedParameter($attendee),

View File

@ -162,7 +162,7 @@ class InvitationResponseController extends Controller {
private function getTokenInformation(string $token) {
$query = $this->db->getQueryBuilder();
$query->select('*')
->from('calendar_invitation_tokens')
->from('calendar_invitations')
->where($query->expr()->eq('token', $query->createNamedParameter($token)));
$stmt = $query->execute();
$row = $stmt->fetch(\PDO::FETCH_ASSOC);

View File

@ -27,9 +27,6 @@ use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1005Date20180530124431 extends SimpleMigrationStep {
/**
@ -45,8 +42,8 @@ class Version1005Date20180530124431 extends SimpleMigrationStep {
$types = ['resources', 'rooms'];
foreach($types as $type) {
if (!$schema->hasTable('calendar_' . $type . '_cache')) {
$table = $schema->createTable('calendar_' . $type . '_cache');
if (!$schema->hasTable('calendar_' . $type)) {
$table = $schema->createTable('calendar_' . $type);
$table->addColumn('id', Type::BIGINT, [
'autoincrement' => true,
@ -75,10 +72,10 @@ class Version1005Date20180530124431 extends SimpleMigrationStep {
'length' => 4000,
]);
$table->setPrimaryKey(['id'], 'calendar_' . $type . '_cache_id_idx');
$table->addIndex(['backend_id', 'resource_id'], 'calendar_' . $type . '_cache_backendresource_idx');
$table->addIndex(['email'], 'calendar_' . $type . '_cache_email_idx');
$table->addIndex(['displayname'], 'calendar_' . $type . '_cache_displayname_idx');
$table->setPrimaryKey(['id']);
$table->addIndex(['backend_id', 'resource_id'], 'calendar_' . $type . '_bkdrsc');
$table->addIndex(['email'], 'calendar_' . $type . '_email');
$table->addIndex(['displayname'], 'calendar_' . $type . '_name');
}
}

View File

@ -22,8 +22,8 @@ class Version1006Date20180619154313 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('calendar_invitation_tokens')) {
$table = $schema->createTable('calendar_invitation_tokens');
if (!$schema->hasTable('calendar_invitations')) {
$table = $schema->createTable('calendar_invitations');
$table->addColumn('id', Type::BIGINT, [
'autoincrement' => true,
@ -62,8 +62,8 @@ class Version1006Date20180619154313 extends SimpleMigrationStep {
'unsigned' => true,
]);
$table->setPrimaryKey(['id'], 'calendar_invitation_tokens_id_idx');
$table->addIndex(['token'], 'calendar_invitation_tokens_token_idx');
$table->setPrimaryKey(['id']);
$table->addIndex(['token'], 'calendar_invitation_tokens');
return $schema;
}

View File

@ -84,7 +84,7 @@ class CleanupInvitationTokenJobTest extends TestCase {
$queryBuilder->expects($this->at(0))
->method('delete')
->with('calendar_invitation_tokens')
->with('calendar_invitations')
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(3))
->method('where')
@ -97,4 +97,4 @@ class CleanupInvitationTokenJobTest extends TestCase {
$this->backgroundJob->run([]);
}
}
}

View File

@ -60,8 +60,8 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
protected function tearDown() {
$query = self::$realDatabase->getQueryBuilder();
$query->delete('calendar_resources_cache')->execute();
$query->delete('calendar_rooms_cache')->execute();
$query->delete('calendar_resources')->execute();
$query->delete('calendar_rooms')->execute();
}
/**
@ -170,7 +170,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
$this->backgroundJob->run([]);
$query = self::$realDatabase->getQueryBuilder();
$query->select('*')->from('calendar_resources_cache');
$query->select('*')->from('calendar_resources');
$rows = [];
$stmt = $query->execute();
@ -227,7 +227,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
protected function createTestResourcesInCache() {
$query = self::$realDatabase->getQueryBuilder();
$query->insert('calendar_resources_cache')
$query->insert('calendar_resources')
->values([
'backend_id' => $query->createNamedParameter('backend1'),
'resource_id' => $query->createNamedParameter('res1'),
@ -236,7 +236,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
'group_restrictions' => $query->createNamedParameter('[]'),
])
->execute();
$query->insert('calendar_resources_cache')
$query->insert('calendar_resources')
->values([
'backend_id' => $query->createNamedParameter('backend1'),
'resource_id' => $query->createNamedParameter('res2'),
@ -245,7 +245,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
'group_restrictions' => $query->createNamedParameter('[]'),
])
->execute();
$query->insert('calendar_resources_cache')
$query->insert('calendar_resources')
->values([
'backend_id' => $query->createNamedParameter('backend2'),
'resource_id' => $query->createNamedParameter('res3'),
@ -254,7 +254,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
'group_restrictions' => $query->createNamedParameter('[]'),
])
->execute();
$query->insert('calendar_resources_cache')
$query->insert('calendar_resources')
->values([
'backend_id' => $query->createNamedParameter('backend2'),
'resource_id' => $query->createNamedParameter('res4'),
@ -263,7 +263,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
'group_restrictions' => $query->createNamedParameter('[]'),
])
->execute();
$query->insert('calendar_resources_cache')
$query->insert('calendar_resources')
->values([
'backend_id' => $query->createNamedParameter('backend3'),
'resource_id' => $query->createNamedParameter('res5'),
@ -272,7 +272,7 @@ class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
'group_restrictions' => $query->createNamedParameter('[]'),
])
->execute();
$query->insert('calendar_resources_cache')
$query->insert('calendar_resources')
->values([
'backend_id' => $query->createNamedParameter('backend3'),
'resource_id' => $query->createNamedParameter('res6'),

View File

@ -29,7 +29,7 @@ Class ResourcePrincipalBackendTest extends AbstractPrincipalBackendTest {
$this->principalBackend = new ResourcePrincipalBackend($this->dbConnection,
$this->userSession, $this->groupManager, $this->logger);
$this->expectedDbTable = 'calendar_resources_cache';
$this->expectedDbTable = 'calendar_resources';
$this->principalPrefix = 'principals/calendar-resources';
}
}

View File

@ -29,7 +29,7 @@ Class RoomPrincipalBackendTest extends AbstractPrincipalBackendTest {
$this->principalBackend = new RoomPrincipalBackend($this->dbConnection,
$this->userSession, $this->groupManager, $this->logger);
$this->expectedDbTable = 'calendar_rooms_cache';
$this->expectedDbTable = 'calendar_rooms';
$this->principalPrefix = 'principals/calendar-rooms';
}
}

View File

@ -96,7 +96,7 @@ class IMipPluginTest extends TestCase {
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(0))
->method('insert')
->with('calendar_invitation_tokens')
->with('calendar_invitations')
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(8))
->method('values')
@ -176,7 +176,7 @@ class IMipPluginTest extends TestCase {
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(0))
->method('insert')
->with('calendar_invitation_tokens')
->with('calendar_invitations')
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(8))
->method('values')
@ -264,7 +264,7 @@ class IMipPluginTest extends TestCase {
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(0))
->method('insert')
->with('calendar_invitation_tokens')
->with('calendar_invitations')
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(8))
->method('values')

View File

@ -438,7 +438,7 @@ EOF;
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(1))
->method('from')
->with('calendar_invitation_tokens')
->with('calendar_invitations')
->will($this->returnValue($queryBuilder));
$queryBuilder->expects($this->at(4))
->method('where')
@ -452,4 +452,4 @@ EOF;
$this->timeFactory->method('getTime')
->will($this->returnValue($time));
}
}
}