summaryrefslogtreecommitdiffstats
path: root/lib/Migration
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-03-05 14:47:04 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-03-05 14:47:04 -0100
commitf74702f440ab25dc1ff6b854e69a56cbc467f3c1 (patch)
treed81e7fb126ad4d2c429bba48ac1479f8802ba360 /lib/Migration
parenta6ad99eed17b0318af731e8452a3eda092a676e6 (diff)
fitting migrations with new master
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Migration')
-rw-r--r--lib/Migration/Version0002Date20190118124201.php143
-rw-r--r--lib/Migration/Version0002Date20190118124202.php75
-rw-r--r--lib/Migration/Version0002Date20190118124203.php112
-rw-r--r--lib/Migration/Version0002Date20190118124204.php77
-rw-r--r--lib/Migration/Version0002Date20190119124417.php11
5 files changed, 2 insertions, 416 deletions
diff --git a/lib/Migration/Version0002Date20190118124201.php b/lib/Migration/Version0002Date20190118124201.php
deleted file mode 100644
index f1b1b8f9..00000000
--- a/lib/Migration/Version0002Date20190118124201.php
+++ /dev/null
@@ -1,143 +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 Version0002Date20190118124201 extends SimpleMigrationStep {
-
-
- /** @var IDBConnection */
- private $connection;
-
-
- /** @var array */
- public static $editToChar2000 = [
- [CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'id'],
- [CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'url'],
- [CoreRequestBuilder::TABLE_CACHE_DOCUMENTS, 'local_copy'],
-
- [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'id'],
- [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'account'],
- [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, 'preferred_username'],
- [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'name'],
- [CoreRequestBuilder::TABLE_CACHE_ACTORS, 'icon_id'],
-
- [CoreRequestBuilder::TABLE_REQUEST_QUEUE, 'author'],
-
- [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, 'id'],
- [CoreRequestBuilder::TABLE_SERVER_NOTES, 'to'],
- [CoreRequestBuilder::TABLE_SERVER_NOTES, 'attributed_to'],
- [CoreRequestBuilder::TABLE_SERVER_NOTES, 'in_reply_to']
- ];
-
-
- /**
- * @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/Version0002Date20190118124202.php b/lib/Migration/Version0002Date20190118124202.php
deleted file mode 100644
index 3047318f..00000000
--- a/lib/Migration/Version0002Date20190118124202.php
+++ /dev/null
@@ -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 Version0001Date20181219000002
- *
- * @package OCA\Social\Migration
- */
-class Version0002Date20190118124202 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 (Version0002Date20190118124201::$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/Version0002Date20190118124203.php b/lib/Migration/Version0002Date20190118124203.php
deleted file mode 100644
index 458a30cb..00000000
--- a/lib/Migration/Version0002Date20190118124203.php
+++ /dev/null
@@ -1,112 +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 Version0002Date20190118124203 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();
-
- // -> VARCHAR(4000)
- foreach (Version0002Date20190118124201::$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 (Version0002Date20190118124201::$editToChar2000 as $edit) {
- list($table, $field) = $edit;
-
- $qb = $this->connection->getQueryBuilder();
- $qb->update($table)
- ->set($field, $field . '_copy')
- ->execute();
- }
- }
-
-}
-
diff --git a/lib/Migration/Version0002Date20190118124204.php b/lib/Migration/Version0002Date20190118124204.php
deleted file mode 100644
index c484c1fd..00000000
--- a/lib/Migration/Version0002Date20190118124204.php
+++ /dev/null
@@ -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 Version0001Date20181219000004
- *
- * @package OCA\Social\Migration
- */
-class Version0002Date20190118124204 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 (Version0002Date20190118124201::$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
index a7fff224..88713d4e 100644
--- a/lib/Migration/Version0002Date20190119124417.php
+++ b/lib/Migration/Version0002Date20190119124417.php
@@ -2,6 +2,7 @@
declare(strict_types=1);
+
/**
* Nextcloud - Social Support
*
@@ -80,19 +81,11 @@ class Version0002Date20190119124417 extends SimpleMigrationStep {
if (!$table->hasColumn('attachments')) {
$table->addColumn('attachments', Type::TEXT, ['notnull' => false]);
}
- $table->setPrimaryKey(['id']);
$table = $schema->getTable(CoreRequestBuilder::TABLE_CACHE_DOCUMENTS);
if (!$table->hasColumn('parent_id')) {
- $table->addColumn('parent_id', Type::STRING, ['notnull' => false, 'length' => 255]);
+ $table->addColumn('parent_id', Type::STRING, ['notnull' => false, 'length' => 1000]);
}
- $table->setPrimaryKey(['id']);
-
- $table = $schema->getTable(CoreRequestBuilder::TABLE_CACHE_ACTORS);
- $table->setPrimaryKey(['id']);
-
- $table = $schema->getTable(CoreRequestBuilder::TABLE_SERVER_FOLLOWS);
- $table->setPrimaryKey(['id']);
return $schema;
}