Refresh on the SQL migrations

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/518/head
Maxence Lange 2019-05-07 14:11:04 -01:00
rodzic 12404d7eaa
commit 7deb98642a
29 zmienionych plików z 1257 dodań i 2362 usunięć

Wyświetl plik

@ -18,7 +18,7 @@
**🕸 Open standards:** We use the established ActivityPub standard!
]]></description>
<version>0.2.0-dev01</version>
<version>0.2.0-dev02</version>
<licence>agpl</licence>
<author mail="maxence@artificial-owl.com">Maxence Lange</author>
<author mail="jus@bitgrid.net">Julius Härtl</author>

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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();
}

Wyświetl plik

@ -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
];

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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));

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -1,353 +0,0 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
}

Wyświetl plik

@ -1,133 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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();
}
}
}

Wyświetl plik

@ -1,79 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
}

Wyświetl plik

@ -1,128 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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();
}
}
}

Wyświetl plik

@ -1,81 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
}

Wyświetl plik

@ -1,118 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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();
}
}
}

Wyświetl plik

@ -1,75 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
}

Wyświetl plik

@ -1,111 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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();
}
}
}

Wyświetl plik

@ -1,77 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
}

Wyświetl plik

@ -1,103 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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) {
}
}

Wyświetl plik

@ -1,157 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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) {
}
}

Wyświetl plik

@ -1,109 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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) {
}
}

Wyświetl plik

@ -1,167 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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, $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
*
* @throws SchemaException
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
foreach (array_merge(self::$editToText, self::$editToChar1000) as $edit) {
list($tableName, $field) = $edit;
$table = $schema->getTable($tableName);
if (!$table->hasColumn($field)) {
continue;
}
$qb = $this->connection->getQueryBuilder();
$qb->update($tableName)
->set($field . '_copy', $field)
->execute();
}
}
}

Wyświetl plik

@ -1,79 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Social\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0002Date20190226000002
*
* @package OCA\Social\Migration
*/
class Version0002Date20190226000002 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(
Version0002Date20190226000001::$editToText,
Version0002Date20190226000001::$editToChar1000
);
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;
}
}

Wyświetl plik

@ -1,128 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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 Version0002Date20190226000003
*
* @package OCA\Social\Migration
*/
class Version0002Date20190226000003 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 (Version0002Date20190226000001::$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 (Version0002Date20190226000001::$editToChar1000 as $edit) {
list($tableName, $field) = $edit;
$table = $schema->getTable($tableName);
if ($table->hasColumn($field)) {
continue;
}
$table->addColumn($field, 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) {
$edits = array_merge(
Version0002Date20190226000001::$editToText,
Version0002Date20190226000001::$editToChar1000
);
foreach ($edits as $edit) {
list($table, $field) = $edit;
$qb = $this->connection->getQueryBuilder();
$qb->update($table)
->set($field, $field . '_copy')
->execute();
}
}
}

Wyświetl plik

@ -1,81 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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 Version0002Date20190226000004
*
* @package OCA\Social\Migration
*/
class Version0002Date20190226000004 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(
Version0002Date20190226000001::$editToText,
Version0002Date20190226000001::$editToChar1000
);
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;
}
}

Wyświetl plik

@ -1,150 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
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 Version0002Date20190305091901
*
* @package OCA\Social\Migration
*/
class Version0002Date20190305091901 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/** @var array */
public static $setAsKeys = [
[CoreRequestBuilder::TABLE_CACHE_ACTORS, 'id'],
[CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'id'],
[CoreRequestBuilder::TABLE_SERVER_ACTORS, 'id'],
[CoreRequestBuilder::TABLE_SERVER_FOLLOWS, 'id'],
[CoreRequestBuilder::TABLE_SERVER_NOTES, 'id']
];
/**
* @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::$setAsKeys as $edit) {
list($tableName, $field) = $edit;
$table = $schema->getTable($tableName);
$prim = self::getPrimField($field);
if (!$table->hasColumn($prim)) {
$table->addColumn($prim, Type::STRING, ['notnull' => false, 'length' => 255]);
}
}
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::$setAsKeys as $edit) {
list($tableName, $field) = $edit;
$prim = self::getPrimField($field);
$qb = $this->connection->getQueryBuilder();
/** @noinspection PhpMethodParametersCountMismatchInspection */
$qb->select('t.' . $field)
->from($tableName, 't');
$cursor = $qb->execute();
while ($data = $cursor->fetch()) {
$id = $data[$field];
$hash = hash('sha512', $id);
$update = $this->connection->getQueryBuilder();
$update->update($tableName);
$update->set($prim, $update->createNamedParameter($hash));
$update->where(
$qb->expr()
->eq($field, $update->createNamedParameter($id))
);
$update->execute();
}
$cursor->closeCursor();
}
}
/**
* @param string $field
*
* @return string
*/
public static function getPrimField(string $field): string {
return $field . '_prim';
}
}

Wyświetl plik

@ -1,99 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Social\Migration;
use Closure;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0002Date20190305091902
*
* @package OCA\Social\Migration
*/
class Version0002Date20190305091902 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 (Version0002Date20190305091901::$setAsKeys as $edit) {
list($tableName, $field) = $edit;
$table = $schema->getTable($tableName);
$prim = Version0002Date20190305091901::getPrimField($field);
$table->setPrimaryKey([$prim]);
}
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) {
}
}

Wyświetl plik

@ -1,94 +0,0 @@
<?php
declare(strict_types=1);
/**
* Nextcloud - Social Support
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
* @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 <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Social\Migration;
use Closure;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0002Date20190313133046
*
* @package OCA\Social\Migration
*/
class Version0002Date20190313133046 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_stream_actions')) {
$table = $schema->createTable('social_stream_actions');
$table->addColumn(
'id', Type::INTEGER, [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true
]
);
$table->addColumn(
'actor_id', 'string', [
'notnull' => true,
'length' => 127,
]
);
$table->addColumn(
'stream_id', 'string', [
'notnull' => true,
'length' => 1000,
]
);
$table->addColumn(
'values', Type::TEXT, [
'notnull' => false
]
);
$table->setPrimaryKey(['id']);
}
return $schema;
}
}