diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-05-07 14:11:04 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-05-08 08:02:34 -0100 |
commit | 7deb98642ab21e94117d215c75999f34e559b31b (patch) | |
tree | d8f4002a44cecb073aa6d9bc3281dd26dbfa2bb6 /lib/Db | |
parent | 12404d7eaa527dd9ae7f0710d9dfb04edf5b4a8c (diff) |
Refresh on the SQL migrations
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/ActorsRequestBuilder.php | 8 | ||||
-rw-r--r-- | lib/Db/CacheDocumentsRequest.php | 4 | ||||
-rw-r--r-- | lib/Db/CoreRequestBuilder.php | 39 | ||||
-rw-r--r-- | lib/Db/FollowsRequestBuilder.php | 10 | ||||
-rw-r--r-- | lib/Db/HashtagsRequestBuilder.php | 8 | ||||
-rw-r--r-- | lib/Db/NotesRequest.php | 2 | ||||
-rw-r--r-- | lib/Db/NotesRequestBuilder.php | 14 | ||||
-rw-r--r-- | lib/Db/StreamQueueRequestBuilder.php | 8 |
8 files changed, 54 insertions, 39 deletions
diff --git a/lib/Db/ActorsRequestBuilder.php b/lib/Db/ActorsRequestBuilder.php index 5263c6e3..b8aafb6c 100644 --- a/lib/Db/ActorsRequestBuilder.php +++ b/lib/Db/ActorsRequestBuilder.php @@ -48,7 +48,7 @@ class ActorsRequestBuilder extends CoreRequestBuilder { */ protected function getActorsInsertSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->insert(self::TABLE_SERVER_ACTORS); + $qb->insert(self::TABLE_ACTORS); return $qb; } @@ -61,7 +61,7 @@ class ActorsRequestBuilder extends CoreRequestBuilder { */ protected function getActorsUpdateSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->update(self::TABLE_SERVER_ACTORS); + $qb->update(self::TABLE_ACTORS); return $qb; } @@ -80,7 +80,7 @@ class ActorsRequestBuilder extends CoreRequestBuilder { 'sa.id', 'sa.user_id', 'sa.preferred_username', 'sa.name', 'sa.summary', 'sa.public_key', 'sa.avatar_version', 'sa.private_key', 'sa.creation' ) - ->from(self::TABLE_SERVER_ACTORS, 'sa'); + ->from(self::TABLE_ACTORS, 'sa'); $this->defaultSelectAlias = 'sa'; @@ -95,7 +95,7 @@ class ActorsRequestBuilder extends CoreRequestBuilder { */ protected function getActorsDeleteSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->delete(self::TABLE_SERVER_ACTORS); + $qb->delete(self::TABLE_ACTORS); return $qb; } diff --git a/lib/Db/CacheDocumentsRequest.php b/lib/Db/CacheDocumentsRequest.php index b095499a..de904d8b 100644 --- a/lib/Db/CacheDocumentsRequest.php +++ b/lib/Db/CacheDocumentsRequest.php @@ -75,7 +75,7 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder { * @param Document $document */ public function update(Document $document) { - $qb = $this->getCacheDocumentsInsertSql(); + $qb = $this->getCacheDocumentsUpdateSql(); $qb->set('type', $qb->createNamedParameter($document->getType())) ->set('url', $qb->createNamedParameter($document->getUrl())) ->set('media_type', $qb->createNamedParameter($document->getMediaType())) @@ -88,6 +88,8 @@ class CacheDocumentsRequest extends CacheDocumentsRequestBuilder { 'creation', $qb->createNamedParameter(new DateTime('now'), IQueryBuilder::PARAM_DATE) ); + + $this->limitToIdString($qb, $document->getId()); $qb->execute(); } diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 2672c562..6bfbd2a4 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -55,18 +55,31 @@ use OCP\IDBConnection; class CoreRequestBuilder { - const TABLE_REQUEST_QUEUE = 'social_request_queue'; +// const TABLE_REQUEST_QUEUE = 'social_request_queue'; +// +// const TABLE_SERVER_ACTORS = 'social_server_actors'; +// const TABLE_SERVER_NOTES = 'social_server_notes'; +// const TABLE_SERVER_HASHTAGS = 'social_server_hashtags'; +// const TABLE_SERVER_FOLLOWS = 'social_server_follows'; +// +// const TABLE_CACHE_ACTORS = 'social_cache_actors'; +// const TABLE_CACHE_DOCUMENTS = 'social_cache_documents'; +// +// const TABLE_QUEUE_STREAM = 'social_queue_stream'; +// const TABLE_STREAM_ACTIONS = 'social_stream_actions'; - const TABLE_SERVER_ACTORS = 'social_server_actors'; - const TABLE_SERVER_NOTES = 'social_server_notes'; - const TABLE_SERVER_HASHTAGS = 'social_server_hashtags'; - const TABLE_SERVER_FOLLOWS = 'social_server_follows'; + const TABLE_REQUEST_QUEUE = 'social_a2_request_queue'; - const TABLE_CACHE_ACTORS = 'social_cache_actors'; - const TABLE_CACHE_DOCUMENTS = 'social_cache_documents'; + const TABLE_ACTORS = 'social_a2_actors'; + const TABLE_STREAMS = 'social_a2_stream'; + const TABLE_HASHTAGS = 'social_a2_hashtags'; + const TABLE_FOLLOWS = 'social_a2_follows'; - const TABLE_QUEUE_STREAM = 'social_queue_stream'; - const TABLE_STREAM_ACTIONS = 'social_stream_actions'; + const TABLE_CACHE_ACTORS = 'social_a2_cache_actors'; + const TABLE_CACHE_DOCUMENTS = 'social_a2_cache_documts'; + + const TABLE_STREAM_QUEUE = 'social_a2_stream_queue'; + const TABLE_STREAM_ACTIONS = 'social_a2_stream_action'; /** @var IDBConnection */ @@ -869,7 +882,7 @@ class CoreRequestBuilder { ->selectAlias($prefix . '_f.follow_id', $prefix . '_follow_id') ->selectAlias($prefix . '_f.creation', $prefix . '_creation') ->leftJoin( - $this->defaultSelectAlias, CoreRequestBuilder::TABLE_SERVER_FOLLOWS, $prefix . '_f', + $this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, $prefix . '_f', $andX ); } @@ -949,9 +962,9 @@ class CoreRequestBuilder { public function emptyAll() { $tables = [ self::TABLE_REQUEST_QUEUE, - self::TABLE_SERVER_ACTORS, - self::TABLE_SERVER_NOTES, - self::TABLE_SERVER_FOLLOWS, + self::TABLE_ACTORS, + self::TABLE_STREAMS, + self::TABLE_FOLLOWS, self::TABLE_CACHE_ACTORS, self::TABLE_CACHE_DOCUMENTS ]; diff --git a/lib/Db/FollowsRequestBuilder.php b/lib/Db/FollowsRequestBuilder.php index ab2729fb..9d08dfbf 100644 --- a/lib/Db/FollowsRequestBuilder.php +++ b/lib/Db/FollowsRequestBuilder.php @@ -55,7 +55,7 @@ class FollowsRequestBuilder extends CoreRequestBuilder { */ protected function getFollowsInsertSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->insert(self::TABLE_SERVER_FOLLOWS); + $qb->insert(self::TABLE_FOLLOWS); return $qb; } @@ -68,7 +68,7 @@ class FollowsRequestBuilder extends CoreRequestBuilder { */ protected function getFollowsUpdateSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->update(self::TABLE_SERVER_FOLLOWS); + $qb->update(self::TABLE_FOLLOWS); return $qb; } @@ -86,7 +86,7 @@ class FollowsRequestBuilder extends CoreRequestBuilder { $qb->select( 'f.id', 'f.type', 'f.actor_id', 'f.object_id', 'f.follow_id', 'f.accepted', 'f.creation' ) - ->from(self::TABLE_SERVER_FOLLOWS, 'f'); + ->from(self::TABLE_FOLLOWS, 'f'); $this->defaultSelectAlias = 'f'; @@ -102,7 +102,7 @@ class FollowsRequestBuilder extends CoreRequestBuilder { protected function countFollowsSelectSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); $qb->selectAlias($qb->createFunction('COUNT(*)'), 'count') - ->from(self::TABLE_SERVER_FOLLOWS, 'f'); + ->from(self::TABLE_FOLLOWS, 'f'); $this->defaultSelectAlias = 'f'; @@ -117,7 +117,7 @@ class FollowsRequestBuilder extends CoreRequestBuilder { */ protected function getFollowsDeleteSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->delete(self::TABLE_SERVER_FOLLOWS); + $qb->delete(self::TABLE_FOLLOWS); return $qb; } diff --git a/lib/Db/HashtagsRequestBuilder.php b/lib/Db/HashtagsRequestBuilder.php index 2297d280..9f8922d4 100644 --- a/lib/Db/HashtagsRequestBuilder.php +++ b/lib/Db/HashtagsRequestBuilder.php @@ -53,7 +53,7 @@ class HashtagsRequestBuilder extends CoreRequestBuilder { */ protected function getHashtagsInsertSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->insert(self::TABLE_SERVER_HASHTAGS); + $qb->insert(self::TABLE_HASHTAGS); return $qb; } @@ -66,7 +66,7 @@ class HashtagsRequestBuilder extends CoreRequestBuilder { */ protected function getHashtagsUpdateSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->update(self::TABLE_SERVER_HASHTAGS); + $qb->update(self::TABLE_HASHTAGS); return $qb; } @@ -82,7 +82,7 @@ class HashtagsRequestBuilder extends CoreRequestBuilder { /** @noinspection PhpMethodParametersCountMismatchInspection */ $qb->select('h.hashtag', 'h.trend') - ->from(self::TABLE_SERVER_HASHTAGS, 'h'); + ->from(self::TABLE_HASHTAGS, 'h'); $this->defaultSelectAlias = 'h'; @@ -97,7 +97,7 @@ class HashtagsRequestBuilder extends CoreRequestBuilder { */ protected function getHashtagsDeleteSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->delete(self::TABLE_SERVER_HASHTAGS); + $qb->delete(self::TABLE_HASHTAGS); return $qb; } diff --git a/lib/Db/NotesRequest.php b/lib/Db/NotesRequest.php index 2e931526..5bbf2478 100644 --- a/lib/Db/NotesRequest.php +++ b/lib/Db/NotesRequest.php @@ -467,7 +467,7 @@ class NotesRequest extends NotesRequestBuilder { $on = $this->exprJoinFollowing($qb, $actor); $on->add($this->exprLimitToRecipient($qb, ACore::CONTEXT_PUBLIC, false)); $on->add($this->exprLimitToRecipient($qb, $actor->getId(), true)); - $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'f', $on); + $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'f', $on); $qb->andWhere($this->exprValueWithinJsonFormat($qb, 'hashtags', '' . $hashtag)); diff --git a/lib/Db/NotesRequestBuilder.php b/lib/Db/NotesRequestBuilder.php index 8caa7846..19334e99 100644 --- a/lib/Db/NotesRequestBuilder.php +++ b/lib/Db/NotesRequestBuilder.php @@ -59,7 +59,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { */ protected function getNotesInsertSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->insert(self::TABLE_SERVER_NOTES); + $qb->insert(self::TABLE_STREAMS); return $qb; } @@ -72,7 +72,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { */ protected function getNotesUpdateSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->update(self::TABLE_SERVER_NOTES); + $qb->update(self::TABLE_STREAMS); return $qb; } @@ -95,7 +95,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { 'sn.attributed_to', 'sn.in_reply_to', 'sn.source', 'sn.local', 'sn.instances', 'sn.creation' ) - ->from(self::TABLE_SERVER_NOTES, 'sn'); + ->from(self::TABLE_STREAMS, 'sn'); $this->defaultSelectAlias = 'sn'; @@ -111,7 +111,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { protected function countNotesSelectSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); $qb->selectAlias($qb->createFunction('COUNT(*)'), 'count') - ->from(self::TABLE_SERVER_NOTES, 'sn'); + ->from(self::TABLE_STREAMS, 'sn'); $this->defaultSelectAlias = 'sn'; @@ -126,7 +126,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { */ protected function getNotesDeleteSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->delete(self::TABLE_SERVER_NOTES); + $qb->delete(self::TABLE_STREAMS); return $qb; } @@ -141,7 +141,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { $on = $this->exprJoinFollowing($qb, $actor, false); $on->add($this->exprLimitToRecipient($qb, ACore::CONTEXT_PUBLIC, false)); $on->add($this->exprLimitToRecipient($qb, $actor->getId(), true)); - $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'f', $on); + $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'f', $on); } @@ -156,7 +156,7 @@ class NotesRequestBuilder extends CoreRequestBuilder { $on = $this->exprJoinFollowing($qb, $actor); - $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'f', $on); + $qb->join($this->defaultSelectAlias, CoreRequestBuilder::TABLE_FOLLOWS, 'f', $on); } diff --git a/lib/Db/StreamQueueRequestBuilder.php b/lib/Db/StreamQueueRequestBuilder.php index b66cec1c..2b4760fe 100644 --- a/lib/Db/StreamQueueRequestBuilder.php +++ b/lib/Db/StreamQueueRequestBuilder.php @@ -47,7 +47,7 @@ class StreamQueueRequestBuilder extends CoreRequestBuilder { */ protected function getStreamQueueInsertSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->insert(self::TABLE_QUEUE_STREAM); + $qb->insert(self::TABLE_STREAM_QUEUE); return $qb; } @@ -60,7 +60,7 @@ class StreamQueueRequestBuilder extends CoreRequestBuilder { */ protected function getStreamQueueUpdateSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->update(self::TABLE_QUEUE_STREAM); + $qb->update(self::TABLE_STREAM_QUEUE); return $qb; } @@ -78,7 +78,7 @@ class StreamQueueRequestBuilder extends CoreRequestBuilder { $qb->select( 'qs.id', 'qs.token', 'qs.stream_id', 'qs.type', 'qs.status', 'qs.tries', 'qs.last' ) - ->from(self::TABLE_QUEUE_STREAM, 'qs'); + ->from(self::TABLE_STREAM_QUEUE, 'qs'); $this->defaultSelectAlias = 'qs'; @@ -93,7 +93,7 @@ class StreamQueueRequestBuilder extends CoreRequestBuilder { */ protected function getStreamQueueDeleteSql(): IQueryBuilder { $qb = $this->dbConnection->getQueryBuilder(); - $qb->delete(self::TABLE_QUEUE_STREAM); + $qb->delete(self::TABLE_STREAM_QUEUE); return $qb; } |