From 7deb98642ab21e94117d215c75999f34e559b31b Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Tue, 7 May 2019 14:11:04 -0100 Subject: Refresh on the SQL migrations Signed-off-by: Maxence Lange --- appinfo/info.xml | 2 +- lib/Db/ActorsRequestBuilder.php | 8 +- lib/Db/CacheDocumentsRequest.php | 4 +- lib/Db/CoreRequestBuilder.php | 39 +- lib/Db/FollowsRequestBuilder.php | 10 +- lib/Db/HashtagsRequestBuilder.php | 8 +- lib/Db/NotesRequest.php | 2 +- lib/Db/NotesRequestBuilder.php | 14 +- lib/Db/StreamQueueRequestBuilder.php | 8 +- lib/Migration/Version0001Date20181204203147.php | 353 ------- lib/Migration/Version0001Date20181219000001.php | 133 --- lib/Migration/Version0001Date20181219000002.php | 79 -- lib/Migration/Version0001Date20181219000003.php | 128 --- lib/Migration/Version0001Date20181219000004.php | 81 -- lib/Migration/Version0001Date20190103000001.php | 118 --- lib/Migration/Version0001Date20190103000002.php | 75 -- lib/Migration/Version0001Date20190103000003.php | 111 --- lib/Migration/Version0001Date20190103000004.php | 77 -- lib/Migration/Version0002Date20190119124417.php | 103 -- lib/Migration/Version0002Date20190121153145.php | 157 --- lib/Migration/Version0002Date20190201000001.php | 109 -- lib/Migration/Version0002Date20190226000001.php | 167 ---- lib/Migration/Version0002Date20190226000002.php | 79 -- lib/Migration/Version0002Date20190226000003.php | 128 --- lib/Migration/Version0002Date20190226000004.php | 81 -- lib/Migration/Version0002Date20190305091901.php | 150 --- lib/Migration/Version0002Date20190305091902.php | 99 -- lib/Migration/Version0002Date20190313133046.php | 94 -- lib/Migration/Version0002Date20190506000001.php | 1202 +++++++++++++++++++++++ 29 files changed, 1257 insertions(+), 2362 deletions(-) delete mode 100644 lib/Migration/Version0001Date20181204203147.php delete mode 100644 lib/Migration/Version0001Date20181219000001.php delete mode 100644 lib/Migration/Version0001Date20181219000002.php delete mode 100644 lib/Migration/Version0001Date20181219000003.php delete mode 100644 lib/Migration/Version0001Date20181219000004.php delete mode 100644 lib/Migration/Version0001Date20190103000001.php delete mode 100644 lib/Migration/Version0001Date20190103000002.php delete mode 100644 lib/Migration/Version0001Date20190103000003.php delete mode 100644 lib/Migration/Version0001Date20190103000004.php delete mode 100644 lib/Migration/Version0002Date20190119124417.php delete mode 100644 lib/Migration/Version0002Date20190121153145.php delete mode 100644 lib/Migration/Version0002Date20190201000001.php delete mode 100644 lib/Migration/Version0002Date20190226000001.php delete mode 100644 lib/Migration/Version0002Date20190226000002.php delete mode 100644 lib/Migration/Version0002Date20190226000003.php delete mode 100644 lib/Migration/Version0002Date20190226000004.php delete mode 100644 lib/Migration/Version0002Date20190305091901.php delete mode 100644 lib/Migration/Version0002Date20190305091902.php delete mode 100644 lib/Migration/Version0002Date20190313133046.php create mode 100644 lib/Migration/Version0002Date20190506000001.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 9f1468c9..482fc6cc 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -18,7 +18,7 @@ **🕸 Open standards:** We use the established ActivityPub standard! ]]> - 0.2.0-dev01 + 0.2.0-dev02 agpl Maxence Lange Julius Härtl 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; } diff --git a/lib/Migration/Version0001Date20181204203147.php b/lib/Migration/Version0001Date20181204203147.php deleted file mode 100644 index c98b319b..00000000 --- a/lib/Migration/Version0001Date20181204203147.php +++ /dev/null @@ -1,353 +0,0 @@ - - * - * @author Roeland Jago Douma - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - -namespace OCA\Social\Migration; - -use Closure; -use OCP\DB\ISchemaWrapper; -use OCP\Migration\SimpleMigrationStep; -use OCP\Migration\IOutput; - -class Version0001Date20181204203147 extends SimpleMigrationStep { - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * @return null|ISchemaWrapper - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - if (!$schema->hasTable('social_server_actors')) { - $table = $schema->createTable('social_server_actors'); - $table->addColumn('id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('user_id', 'string', [ - 'notnull' => true, - 'length' => 63, - ]); - $table->addColumn('preferred_username', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('name', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('summary', 'string', [ - 'notnull' => true, - 'length' => 3000, - ]); - $table->addColumn('public_key', 'string', [ - 'notnull' => false, - 'length' => 1000, - ]); - $table->addColumn('private_key', 'string', [ - 'notnull' => false, - 'length' => 2000, - ]); - $table->addColumn('avatar_version', 'integer', [ - 'notnull' => false, - 'length' => 2, - ]); - $table->addColumn('creation', 'datetime', [ - 'notnull' => false, - ]); - $table->setPrimaryKey(['id']); - } - - if (!$schema->hasTable('social_server_follows')) { - $table = $schema->createTable('social_server_follows'); - $table->addColumn('id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('type', 'string', [ - 'notnull' => false, - 'length' => 31, - ]); - $table->addColumn('actor_id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('object_id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('follow_id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('accepted', 'boolean', [ - 'notnull' => true, - 'default' => false - ]); - $table->addColumn('creation', 'datetime', [ - 'notnull' => false, - ]); - $table->setPrimaryKey(['id']); - } - - if (!$schema->hasTable('social_server_notes')) { - $table = $schema->createTable('social_server_notes'); - $table->addColumn('id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('type', 'string', [ - 'notnull' => true, - 'length' => 31, - ]); - $table->addColumn('to', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('to_array', 'string', [ - 'notnull' => true, - 'length' => 2000, - ]); - $table->addColumn('cc', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('bcc', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('content', 'string', [ - 'notnull' => true, - 'length' => 3000, - ]); - $table->addColumn('summary', 'string', [ - 'notnull' => true, - 'length' => 3000, - ]); - $table->addColumn('published', 'string', [ - 'notnull' => true, - 'length' => 31, - ]); - $table->addColumn('published_time', 'datetime', [ - 'notnull' => false, - ]); - $table->addColumn('attributed_to', 'string', [ - 'notnull' => false, - 'length' => 127, - ]); - $table->addColumn('in_reply_to', 'string', [ - 'notnull' => false, - 'length' => 127, - ]); - $table->addColumn('source', 'string', [ - 'notnull' => true, - 'length' => 3000, - ]); - $table->addColumn('instances', 'string', [ - 'notnull' => true, - 'length' => 3000, - ]); - $table->addColumn('creation', 'datetime', [ - 'notnull' => false, - ]); - $table->addColumn('local', 'boolean', [ - 'notnull' => true, - 'default' => false - ]); - $table->setPrimaryKey(['id']); - } - - if (!$schema->hasTable('social_cache_actors')) { - $table = $schema->createTable('social_cache_actors'); - $table->addColumn('id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('type', 'string', [ - 'notnull' => true, - 'length' => 31, - ]); - $table->addColumn('account', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('local', 'boolean', [ - 'notnull' => true, - 'default' => false - ]); - $table->addColumn('following', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('followers', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('inbox', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('shared_inbox', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('outbox', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('featured', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('url', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('preferred_username', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('name', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('icon_id', 'string', [ - 'notnull' => false, - 'length' => 127, - ]); - $table->addColumn('summary', 'string', [ - 'notnull' => true, - 'length' => 3000, - ]); - $table->addColumn('public_key', 'string', [ - 'notnull' => true, - 'length' => 500, - ]); - $table->addColumn('source', 'string', [ - 'notnull' => true, - 'length' => 3000, - ]); - $table->addColumn('details', 'string', [ - 'notnull' => false, - 'length' => 3000, - ]); - $table->addColumn('creation', 'datetime', [ - 'notnull' => false, - ]); - $table->setPrimaryKey(['id']); - } - - if (!$schema->hasTable('social_cache_documents')) { - $table = $schema->createTable('social_cache_documents'); - $table->addColumn('id', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('type', 'string', [ - 'notnull' => true, - 'length' => 31, - ]); - $table->addColumn('media_type', 'string', [ - 'notnull' => true, - 'length' => 63, - ]); - $table->addColumn('mime_type', 'string', [ - 'notnull' => true, - 'length' => 63, - ]); - $table->addColumn('url', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('local_copy', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('public', 'boolean', [ - 'notnull' => true, - 'default' => false - ]); - $table->addColumn('error', 'smallint', [ - 'notnull' => true, - 'length' => 1, - ]); - $table->addColumn('creation', 'datetime', [ - 'notnull' => false, - ]); - $table->addColumn('caching', 'datetime', [ - 'notnull' => false, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['url'], 'unique_url'); - } - - if (!$schema->hasTable('social_request_queue')) { - $table = $schema->createTable('social_request_queue'); - $table->addColumn('id', 'bigint', [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 11, - 'unsigned' => true, - ]); - $table->addColumn('token', 'string', [ - 'notnull' => true, - 'length' => 63, - ]); - $table->addColumn('author', 'string', [ - 'notnull' => true, - 'length' => 127, - ]); - $table->addColumn('activity', 'string', [ - 'notnull' => true, - 'length' => 6000, - ]); - $table->addColumn('instance', 'string', [ - 'notnull' => false, - 'length' => 500, - ]); - $table->addColumn('priority', 'smallint', [ - 'notnull' => false, - 'length' => 1, - 'default' => 0, - ]); - $table->addColumn('status', 'smallint', [ - 'notnull' => false, - 'length' => 1, - 'default' => 0, - ]); - $table->addColumn('tries', 'smallint', [ - 'notnull' => false, - 'length' => 2, - 'default' => 0, - ]); - $table->addColumn('last', 'datetime', [ - 'notnull' => false, - ]); - $table->setPrimaryKey(['id']); - } - return $schema; - } -} diff --git a/lib/Migration/Version0001Date20181219000001.php b/lib/Migration/Version0001Date20181219000001.php deleted file mode 100644 index 57eda132..00000000 --- a/lib/Migration/Version0001Date20181219000001.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCA\Social\Db\CoreRequestBuilder; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20181219000001 - * - * @package OCA\Social\Migration - */ -class Version0001Date20181219000001 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** @var array */ - public static $editToText = [ - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'source'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'summary'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'details'], - [CoreRequestBuilder::TABLE_REQUEST_QUEUE, 'activity'], - [CoreRequestBuilder::TABLE_SERVER_ACTORS, 'summary'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'content'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'summary'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'instances'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'source'] - ]; - - /** @var array */ - public static $editToChar4000 = [ - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'to_array'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'cc'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'bcc'] - ]; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - foreach (array_merge(self::$editToText, self::$editToChar4000) as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field . '_copy')) { - continue; - } - - $table->addColumn($field . '_copy', Type::TEXT, ['notnull' => false]); - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - - foreach (array_merge(self::$editToText, self::$editToChar4000) as $edit) { - list($tableName, $field) = $edit; - - $qb = $this->connection->getQueryBuilder(); - $qb->update($tableName) - ->set($field . '_copy', $field) - ->execute(); - } - } - -} - diff --git a/lib/Migration/Version0001Date20181219000002.php b/lib/Migration/Version0001Date20181219000002.php deleted file mode 100644 index 949c5171..00000000 --- a/lib/Migration/Version0001Date20181219000002.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\Schema\SchemaException; -use OCP\DB\ISchemaWrapper; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20181219000002 - * - * @package OCA\Social\Migration - */ -class Version0001Date20181219000002 extends SimpleMigrationStep { - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - $edits = array_merge( - Version0001Date20181219000001::$editToText, - Version0001Date20181219000001::$editToChar4000 - ); - foreach ($edits as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field) && $table->hasColumn($field . '_copy')) { - $table->dropColumn($field); - } - } - - return $schema; - } - -} - diff --git a/lib/Migration/Version0001Date20181219000003.php b/lib/Migration/Version0001Date20181219000003.php deleted file mode 100644 index 4526d938..00000000 --- a/lib/Migration/Version0001Date20181219000003.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20181219000003 - * - * @package OCA\Social\Migration - */ -class Version0001Date20181219000003 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - // -> TEXT - foreach (Version0001Date20181219000001::$editToText as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field)) { - continue; - } - - $table->addColumn($field, Type::TEXT, ['notnull' => false]); - } - - // -> VARCHAR(4000) - foreach (Version0001Date20181219000001::$editToChar4000 as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field)) { - continue; - } - - $table->addColumn($field, Type::STRING, ['notnull' => false, 'length' => 4000]); - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - - $edits = array_merge( - Version0001Date20181219000001::$editToText, - Version0001Date20181219000001::$editToChar4000 - ); - foreach ($edits as $edit) { - list($table, $field) = $edit; - - $qb = $this->connection->getQueryBuilder(); - $qb->update($table) - ->set($field, $field . '_copy') - ->execute(); - } - } - -} - diff --git a/lib/Migration/Version0001Date20181219000004.php b/lib/Migration/Version0001Date20181219000004.php deleted file mode 100644 index 6d68343f..00000000 --- a/lib/Migration/Version0001Date20181219000004.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use OCP\DB\ISchemaWrapper; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20181219000004 - * - * @package OCA\Social\Migration - */ -class Version0001Date20181219000004 extends SimpleMigrationStep { - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - $edits = array_merge( - Version0001Date20181219000001::$editToText, - Version0001Date20181219000001::$editToChar4000 - ); - foreach ($edits as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field) && $table->hasColumn($field . '_copy')) { - $table->dropColumn($field . '_copy'); - } - } - - return $schema; - } - -} - diff --git a/lib/Migration/Version0001Date20190103000001.php b/lib/Migration/Version0001Date20190103000001.php deleted file mode 100644 index 16f12e3f..00000000 --- a/lib/Migration/Version0001Date20190103000001.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCA\Social\Db\CoreRequestBuilder; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20190103000001 - * - * @package OCA\Social\Migration - */ -class Version0001Date20190103000001 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** @var array */ - public static $editToChar2000 = [ - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'public_key'] - ]; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - foreach (self::$editToChar2000 as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field . '_copy')) { - continue; - } - - $table->addColumn($field . '_copy', Type::TEXT, ['notnull' => false]); - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - - foreach (self::$editToChar2000 as $edit) { - list($tableName, $field) = $edit; - - $qb = $this->connection->getQueryBuilder(); - $qb->update($tableName) - ->set($field . '_copy', $field) - ->execute(); - } - } - -} - diff --git a/lib/Migration/Version0001Date20190103000002.php b/lib/Migration/Version0001Date20190103000002.php deleted file mode 100644 index f5ffd60b..00000000 --- a/lib/Migration/Version0001Date20190103000002.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\Schema\SchemaException; -use OCP\DB\ISchemaWrapper; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20190103000002 - * - * @package OCA\Social\Migration - */ -class Version0001Date20190103000002 extends SimpleMigrationStep { - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - foreach (Version0001Date20190103000001::$editToChar2000 as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field) && $table->hasColumn($field . '_copy')) { - $table->dropColumn($field); - } - } - - return $schema; - } - -} - diff --git a/lib/Migration/Version0001Date20190103000003.php b/lib/Migration/Version0001Date20190103000003.php deleted file mode 100644 index 06d7b10d..00000000 --- a/lib/Migration/Version0001Date20190103000003.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20190103000003 - * - * @package OCA\Social\Migration - */ -class Version0001Date20190103000003 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - foreach (Version0001Date20190103000001::$editToChar2000 as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field)) { - continue; - } - - $table->addColumn($field, Type::STRING, ['notnull' => false, 'length' => 2000]); - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - - foreach (Version0001Date20190103000001::$editToChar2000 as $edit) { - list($table, $field) = $edit; - - $qb = $this->connection->getQueryBuilder(); - $qb->update($table) - ->set($field, $field . '_copy') - ->execute(); - } - } - -} - diff --git a/lib/Migration/Version0001Date20190103000004.php b/lib/Migration/Version0001Date20190103000004.php deleted file mode 100644 index 1a51c6ac..00000000 --- a/lib/Migration/Version0001Date20190103000004.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use OCP\DB\ISchemaWrapper; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20190103000004 - * - * @package OCA\Social\Migration - */ -class Version0001Date20190103000004 extends SimpleMigrationStep { - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - foreach (Version0001Date20190103000001::$editToChar2000 as $edit) { - list($tableName, $field) = $edit; - - $table = $schema->getTable($tableName); - if ($table->hasColumn($field) && $table->hasColumn($field . '_copy')) { - $table->dropColumn($field . '_copy'); - } - } - - return $schema; - } - -} - diff --git a/lib/Migration/Version0002Date20190119124417.php b/lib/Migration/Version0002Date20190119124417.php deleted file mode 100644 index 88713d4e..00000000 --- a/lib/Migration/Version0002Date20190119124417.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCA\Social\Db\CoreRequestBuilder; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0002Date20190108103942 - * - * @package OCA\Social\Migration - */ -class Version0002Date20190119124417 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES); - if (!$table->hasColumn('attachments')) { - $table->addColumn('attachments', Type::TEXT, ['notnull' => false]); - } - - $table = $schema->getTable(CoreRequestBuilder::TABLE_CACHE_DOCUMENTS); - if (!$table->hasColumn('parent_id')) { - $table->addColumn('parent_id', Type::STRING, ['notnull' => false, 'length' => 1000]); - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - } - -} - diff --git a/lib/Migration/Version0002Date20190121153145.php b/lib/Migration/Version0002Date20190121153145.php deleted file mode 100644 index 76b71532..00000000 --- a/lib/Migration/Version0002Date20190121153145.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCA\Social\Db\CoreRequestBuilder; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0001Date20190121153145 - * - * @package OCA\Social\Migration - */ -class Version0002Date20190121153145 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES); - if (!$table->hasColumn('cache')) { - $table->addColumn('cache', Type::TEXT, ['notnull' => false]); - } - - $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES); - if (!$table->hasColumn('activity_id')) { - $table->addColumn('activity_id', Type::STRING, ['notnull' => false, 'length' => 1000]); - } - - $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES); - if (!$table->hasColumn('object_id')) { - $table->addColumn('object_id', Type::STRING, ['notnull' => false, 'length' => 1000]); - } - - if (!$schema->hasTable(CoreRequestBuilder::TABLE_QUEUE_STREAM)) { - $table = $schema->createTable(CoreRequestBuilder::TABLE_QUEUE_STREAM); - $table->addColumn( - 'id', 'bigint', [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 11, - 'unsigned' => true, - ] - ); - $table->addColumn( - 'token', 'string', [ - 'notnull' => true, - 'length' => 63, - ] - ); - $table->addColumn( - 'stream_id', 'string', [ - 'notnull' => true, - 'length' => 255, - ] - ); - $table->addColumn( - 'type', 'string', [ - 'notnull' => true, - 'length' => 31, - ] - ); - $table->addColumn( - 'status', 'smallint', [ - 'notnull' => false, - 'length' => 1, - 'default' => 0, - ] - ); - $table->addColumn( - 'tries', 'smallint', [ - 'notnull' => false, - 'length' => 2, - 'default' => 0, - ] - ); - $table->addColumn( - 'last', 'datetime', [ - 'notnull' => false, - ] - ); - $table->setPrimaryKey(['id']); - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - } - -} - diff --git a/lib/Migration/Version0002Date20190201000001.php b/lib/Migration/Version0002Date20190201000001.php deleted file mode 100644 index a4854098..00000000 --- a/lib/Migration/Version0002Date20190201000001.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCA\Social\Db\CoreRequestBuilder; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0002Date20190201000001 - * - * @package OCA\Social\Migration - */ -class Version0002Date20190201000001 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - if (!$schema->hasTable(CoreRequestBuilder::TABLE_SERVER_HASHTAGS)) { - $table = $schema->createTable(CoreRequestBuilder::TABLE_SERVER_HASHTAGS); - $table->addColumn('hashtag', 'string', ['notnull' => false, 'length' => 63]); - $table->addColumn( - 'trend', 'string', ['notnull' => false, 'length' => 500] - ); - $table->setPrimaryKey(['hashtag']); - } - - - $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_NOTES); - if (!$table->hasColumn('hashtags')) { - $table->addColumn( - 'hashtags', Type::STRING, ['notnull' => false, 'default' => '[]', 'length' => 1000] - ); - } - - return $schema; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - } - -} - diff --git a/lib/Migration/Version0002Date20190226000001.php b/lib/Migration/Version0002Date20190226000001.php deleted file mode 100644 index a0408fa6..00000000 --- a/lib/Migration/Version0002Date20190226000001.php +++ /dev/null @@ -1,167 +0,0 @@ - - * @copyright 2018, Maxence Lange - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ - - -namespace OCA\Social\Migration; - - -use Closure; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; -use OCA\Social\Db\CoreRequestBuilder; -use OCP\DB\ISchemaWrapper; -use OCP\IDBConnection; -use OCP\Migration\IOutput; -use OCP\Migration\SimpleMigrationStep; - - -/** - * Class Version0002Date20190226000001 - * - * @package OCA\Social\Migration - */ -class Version0002Date20190226000001 extends SimpleMigrationStep { - - - /** @var IDBConnection */ - private $connection; - - - /** @var array */ - public static $editToChar1000 = [ - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'id'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'following'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'followers'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'inbox'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'shared_inbox'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'outbox'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'featured'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'url'], - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'icon_id'], - - [CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'id'], - [CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'url'], - [CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'local_copy'], - - [CoreRequestBuilder::TABLE_REQUEST_QUEUE, 'author'], - - [CoreRequestBuilder::TABLE_SERVER_ACTORS, 'id'], - - [CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'id'], - [CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'actor_id'], - [CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'object_id'], - [CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'follow_id'], - - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'to_array'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'cc'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'bcc'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'id'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'to'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'attributed_to'], - [CoreRequestBuilder::TABLE_SERVER_NOTES, 'in_reply_to'] - ]; - - /** @var array */ - public static $editToText = [ - [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'public_key'], - - [CoreRequestBuilder::TABLE_REQUEST_QUEUE, 'instance'], - - [CoreRequestBuilder::TABLE_SERVER_ACTORS, 'public_key'], - [CoreRequestBuilder::TABLE_SERVER_ACTORS, 'private_key'] - ]; - - - /** - * @param IDBConnection $connection - */ - public function __construct(IDBConnection $connection) { - $this->connection = $connection; - } - - - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * - * @return ISchemaWrapper - * @throws SchemaException - * @throws DBALException - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options - ): ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); - - foreach (array_merge(self::$editToText, self::$editToChar1000) as $edit) { - list($tableName, $fi