From b7de6d7a24f76c91dffe1644c4b24e0a27b43c14 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 12 Jul 2018 11:55:19 +0200 Subject: [PATCH 1/2] Shorten resource table names to allow install on oracle again Signed-off-by: Joas Schilling --- ...dateCalendarResourcesRoomsBackgroundJob.php | 4 ++-- .../AbstractPrincipalBackend.php | 2 +- .../Version1005Date20180530124431.php | 15 ++++++--------- ...CalendarResourcesRoomsBackgroundJobTest.php | 18 +++++++++--------- .../ResourcePrincipalBackendTest.php | 2 +- .../RoomPrincipalBackendTest.php | 2 +- 6 files changed, 20 insertions(+), 23 deletions(-) diff --git a/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php b/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php index a01540a629..c5f8f6586e 100644 --- a/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php +++ b/apps/dav/lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php @@ -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 diff --git a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php index 135bbe5827..dcd393b512 100644 --- a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php +++ b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php @@ -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; } /** diff --git a/apps/dav/lib/Migration/Version1005Date20180530124431.php b/apps/dav/lib/Migration/Version1005Date20180530124431.php index ae9a40dc5b..6f3d6b9cc1 100644 --- a/apps/dav/lib/Migration/Version1005Date20180530124431.php +++ b/apps/dav/lib/Migration/Version1005Date20180530124431.php @@ -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'); } } diff --git a/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php index 56f768ceda..e012d5e3f1 100644 --- a/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php @@ -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'), diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php index f2c6b6f5f5..90db4bb4b7 100644 --- a/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php @@ -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'; } } diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php index f45121f454..b55c6ddceb 100644 --- a/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php @@ -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'; } } From daed1bed57811b677073f4678ef35ea86c8e7a1d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 12 Jul 2018 12:11:11 +0200 Subject: [PATCH 2/2] Also shorten the name of the invitation tokens Signed-off-by: Joas Schilling --- apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php | 2 +- apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 2 +- apps/dav/lib/Controller/InvitationResponseController.php | 2 +- apps/dav/lib/Migration/Version1006Date20180619154313.php | 8 ++++---- .../unit/BackgroundJob/CleanupInvitationTokenJobTest.php | 4 ++-- apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php | 6 +++--- .../unit/Controller/InvitationResponseControllerTest.php | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php b/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php index e855b57ee9..942f8e23ec 100644 --- a/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php +++ b/apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php @@ -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(); diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 40b4ee355f..4065c21b8a 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -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), diff --git a/apps/dav/lib/Controller/InvitationResponseController.php b/apps/dav/lib/Controller/InvitationResponseController.php index 08298a29f0..e3bdab90aa 100644 --- a/apps/dav/lib/Controller/InvitationResponseController.php +++ b/apps/dav/lib/Controller/InvitationResponseController.php @@ -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); diff --git a/apps/dav/lib/Migration/Version1006Date20180619154313.php b/apps/dav/lib/Migration/Version1006Date20180619154313.php index 8fb82ffed6..91d4826c27 100644 --- a/apps/dav/lib/Migration/Version1006Date20180619154313.php +++ b/apps/dav/lib/Migration/Version1006Date20180619154313.php @@ -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; } diff --git a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php index 3e69230f44..2d80b5bf0e 100644 --- a/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php +++ b/apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php @@ -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([]); } -} \ No newline at end of file +} diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index 2fefe8dd06..c95b32041e 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -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') diff --git a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php index 333737e226..7efb64e3dd 100644 --- a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php +++ b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php @@ -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)); } -} \ No newline at end of file +}