migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,226 @@
<?php
/**
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.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\Circles\Migration;
use OCA\Circles\Model\DeprecatedCircle;
use OCA\Circles\Model\DeprecatedMember;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
use OCP\Share;
/**
* Class ImportOwncloudCustomGroups
*
* @package OCA\Circles\Migration
*/
class ImportOwncloudCustomGroups implements IRepairStep {
/** @var IDBConnection */
protected $connection;
/** @var IConfig */
protected $config;
/** @var array */
protected $circlesById = [];
/** @var array */
protected $circlesByUri = [];
/** @var array */
protected $circleHasAdmin = [];
public function __construct(IDBConnection $connection, IConfig $config) {
$this->connection = $connection;
$this->config = $config;
}
/**
* Returns the step's name
*
* @return string
* @since 9.1.0
*/
public function getName() {
return 'Fix the share type of guest shares when migrating from ownCloud';
}
/**
* @param IOutput $output
*/
public function run(IOutput $output) {
if (!$this->shouldRun()) {
return;
}
$this->createCircles($output);
$this->createMemberships($output);
$this->updateShares($output);
$this->config->setAppValue('circles', 'imported_custom_groups', 'true');
}
/**
* @param IOutput $output
*/
public function createCircles(IOutput $output) {
$output->info('Creating circles');
$select = $this->connection->getQueryBuilder();
$select->select('*')
->from('custom_group')
->orderBy('group_id');
$insert = $this->connection->getQueryBuilder();
$insert->insert('circle_circles')
->values([
'name' => $insert->createParameter('name'),
'type' => $insert->createParameter('type'),
'creation' => $insert->createFunction('NOW()'),
]);
$output->startProgress();
$result = $select->execute();
while ($row = $result->fetch()) {
$insert->setParameter('name', $row['display_name'])
->setParameter('type', DeprecatedCircle::CIRCLES_CLOSED);
$insert->execute();
$output->advance();
$this->circlesById[$row['groud_id']] = $insert->getLastInsertId();
$this->circlesByUri[$row['uri']] = $this->circlesById[$row['groud_id']];
}
$result->closeCursor();
$output->finishProgress();
}
/**
* @param IOutput $output
*/
public function createMemberships(IOutput $output) {
$output->info('Creating memberships');
$select = $this->connection->getQueryBuilder();
$select->select('*')
->from('custom_group_member')
->orderBy('group_id');
$insert = $this->connection->getQueryBuilder();
$insert->insert('circle_members')
->values([
'circle_id' => $insert->createParameter('circle_id'),
'user_id' => $insert->createParameter('user_id'),
'level' => $insert->createParameter('level'),
'status' => $insert->createParameter('status'),
'joined' => $insert->createFunction('NOW()'),
]);
$output->startProgress();
$result = $select->execute();
while ($row = $result->fetch()) {
if (!isset($this->circlesById[$row['group_id']])) {
// Stray membership
continue;
}
$level = (int) $row['role'] === 1 ? DeprecatedMember::LEVEL_OWNER : DeprecatedMember::LEVEL_MEMBER;
if ($level === DeprecatedMember::LEVEL_OWNER) {
if (isset($this->circleHasAdmin[$this->circlesById[$row['group_id']]])) {
$level = DeprecatedMember::LEVEL_MODERATOR;
} else {
$this->circleHasAdmin[$this->circlesById[$row['group_id']]] = $row['user_id'];
}
}
$insert->setParameter('circle_id', $this->circlesById[$row['group_id']])
->setParameter('user_id', $row['user_id'])
->setParameter('level', $level)
->setParameter('status', 'Member');
$insert->execute();
$output->advance();
}
$result->closeCursor();
$output->finishProgress();
}
/**
* Update shares
* - type 7 instead of 1
* - with circle ID instead of `customgroup_` + group URI
*
* @param IOutput $output
*/
public function updateShares(IOutput $output) {
$output->info('Update shares from custom groups to circles');
$select = $this->connection->getQueryBuilder();
$select->select('*')
->from('share')
->where($select->expr()->eq('share_type', $select->createNamedParameter(Share::SHARE_TYPE_GROUP)));
$update = $this->connection->getQueryBuilder();
$update->update('share')
->set('share_type', $update->createParameter('type'))
->set('share_with', $update->createParameter('with'))
->where($update->expr()->eq('id', $update->createParameter('id')));
$output->startProgress();
$result = $select->execute();
while ($row = $result->fetch()) {
$with = $row['share_with'];
if (strpos($with, 'customgroup_') !== 0) {
// Stray membership
continue;
}
$groupUri = substr($with, strlen('customgroup_'));
if ($groupUri === '' || !isset($this->circlesByUri[$groupUri])) {
// Not a customgroup
continue;
}
$update->setParameter('type', Share::SHARE_TYPE_CIRCLE)
->setParameter('with', $this->circlesByUri[$groupUri])
->setParameter('id', $row['id']);
$update->execute();
$output->advance();
}
$result->closeCursor();
$output->finishProgress();
}
protected function shouldRun() {
$alreadyImported = $this->config->getAppValue('circles', 'imported_custom_groups', 'false');
return !$alreadyImported && $this->connection->tableExists('custom_group') && $this->connection->tableExists('custom_group_member');
}
}
@@ -0,0 +1,102 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2021
* @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\Circles\Migration;
use OCA\Circles\Tools\Traits\TNCLogger;
use Exception;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\MigrationService;
use OCA\Circles\Service\OutputService;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
/**
* Class Migration
*
* @package OCA\Circles\Migration
*/
class Migration implements IRepairStep {
use TNCLogger;
/** @var MigrationService */
private $migrationService;
private $outputService;
/** @var ConfigService */
private $configService;
/**
* Migration constructor.
*
* @param MigrationService $migrationService
* @param OutputService $outputService
* @param ConfigService $configService
*/
public function __construct(
MigrationService $migrationService,
OutputService $outputService,
ConfigService $configService
) {
$this->migrationService = $migrationService;
$this->outputService = $outputService;
$this->configService = $configService;
}
/**
* @return string
*/
public function getName(): string {
return 'Upgrading Circles App';
}
/**
* @param IOutput $output
*/
public function run(IOutput $output) {
if ($this->configService->getAppValueBool(ConfigService::MIGRATION_BYPASS)) {
return;
}
$this->outputService->setMigrationOutput($output);
try {
$this->migrationService->migration();
} catch (Exception $e) {
$this->e($e);
}
}
}
@@ -0,0 +1,87 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2021
* @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\Circles\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OC\DB\Connection;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0021Date20210105123456
*
* @package OCA\Circles\Migration
*/
class Version0022Date20220526111723 extends SimpleMigrationStep {
/** @var Connection */
private $connection;
/**
* @param Connection $connection
*/
public function __construct(Connection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
// check if migration to 22 already done
if ($schema->hasTable('circles_event')) {
return $schema;
}
$prefix = $this->connection->getPrefix();
$tables = $schema->getTables();
foreach ($tables as $table) {
$tableName = $table->getName();
if (substr($tableName, 0, 8 + strlen($prefix)) === $prefix . 'circles_') {
$tableName = substr($tableName, strlen($prefix));
$schema->dropTable($tableName);
}
}
return $schema;
}
}
@@ -0,0 +1,670 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2021
* @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\Circles\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0022Date20220526113601
*
* @package OCA\Circles\Migration
*/
class Version0022Date20220526113601 extends SimpleMigrationStep {
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
/**
* CIRCLES_CIRCLE
*/
if (!$schema->hasTable('circles_circle')) {
$table = $schema->createTable('circles_circle');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
'unsigned' => true,
]
);
$table->addColumn(
'unique_id', 'string', [
'notnull' => true,
'length' => 31,
]
);
$table->addColumn(
'name', 'string', [
'notnull' => true,
'length' => 127,
]
);
$table->addColumn(
'display_name', 'string', [
'notnull' => false,
'default' => '',
'length' => 255
]
);
$table->addColumn(
'sanitized_name', 'string', [
'notnull' => false,
'default' => '',
'length' => 127
]
);
$table->addColumn(
'instance', 'string', [
'notnull' => false,
'default' => '',
'length' => 255
]
);
$table->addColumn(
'config', 'integer', [
'notnull' => false,
'length' => 11,
'unsigned' => true
]
);
$table->addColumn(
'source', 'integer', [
'notnull' => false,
'length' => 5,
'unsigned' => true
]
);
$table->addColumn(
'settings', 'text', [
'notnull' => false
]
);
$table->addColumn(
'description', 'text', [
'notnull' => false
]
);
$table->addColumn(
'creation', 'datetime', [
'notnull' => false,
]
);
$table->addColumn(
'contact_addressbook', 'integer', [
'notnull' => false,
'unsigned' => true,
'length' => 7,
]
);
$table->addColumn(
'contact_groupname', 'string', [
'notnull' => false,
'length' => 127,
]
);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['unique_id']);
$table->addIndex(['config']);
$table->addIndex(['instance']);
$table->addIndex(['source']);
$table->addIndex(['sanitized_name']);
}
/**
* CIRCLES_MEMBER
*/
if (!$schema->hasTable('circles_member')) {
$table = $schema->createTable('circles_member');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
'unsigned' => true,
]
);
$table->addColumn(
'single_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'circle_id', 'string', [
'notnull' => true,
'length' => 31,
]
);
$table->addColumn(
'member_id', Types::STRING, [
'notnull' => false,
'length' => 31,
]
);
$table->addColumn(
'user_id', 'string', [
'notnull' => true,
'length' => 127,
]
);
$table->addColumn(
'user_type', 'smallint', [
'notnull' => true,
'length' => 1,
'default' => 1,
]
);
$table->addColumn(
'instance', 'string', [
'default' => '',
'length' => 255
]
);
$table->addColumn(
'invited_by', 'string', [
'notnull' => false,
'length' => 31,
]
);
$table->addColumn(
'level', 'smallint', [
'notnull' => true,
'length' => 1,
]
);
$table->addColumn(
'status', 'string', [
'notnull' => false,
'length' => 15,
]
);
$table->addColumn(
'note', 'text', [
'notnull' => false
]
);
$table->addColumn(
'cached_name', 'string', [
'notnull' => false,
'length' => 255,
'default' => ''
]
);
$table->addColumn(
'cached_update', 'datetime', [
'notnull' => false,
]
);
$table->addColumn(
'contact_id', 'string', [
'notnull' => false,
'length' => 127,
]
);
$table->addColumn(
'contact_meta', 'text', [
'notnull' => false
]
);
$table->addColumn(
'joined', 'datetime', [
'notnull' => false,
]
);
$table->setPrimaryKey(['id']);
$table->addIndex(
['circle_id', 'single_id', 'user_id', 'user_type', 'instance', 'level'],
'circles_member_cisiuiutil'
);
$table->addIndex(['circle_id', 'single_id'], 'circles_member_cisi');
$table->addIndex(['contact_id']);
}
/**
* CIRCLES_REMOTE
*/
if (!$schema->hasTable('circles_remote')) {
$table = $schema->createTable('circles_remote');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
'unsigned' => true,
]
);
$table->addColumn(
'type', 'string', [
'notnull' => true,
'length' => 15,
'default' => 'Unknown'
]
);
$table->addColumn(
'interface', 'integer', [
'notnull' => true,
'length' => 1,
'default' => 0
]
);
$table->addColumn(
'uid', 'string', [
'notnull' => false,
'length' => 20,
]
);
$table->addColumn(
'instance', 'string', [
'notnull' => false,
'length' => 127,
]
);
$table->addColumn(
'href', 'string', [
'notnull' => false,
'length' => 254,
]
);
$table->addColumn(
'item', 'text', [
'notnull' => false,
]
);
$table->addColumn(
'creation', 'datetime', [
'notnull' => false,
]
);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['instance']);
$table->addIndex(['uid']);
$table->addIndex(['href']);
}
/**
* CIRCLES_EVENT
*/
if (!$schema->hasTable('circles_event')) {
$table = $schema->createTable('circles_event');
$table->addColumn(
'token', 'string', [
'notnull' => false,
'length' => 63,
]
);
$table->addColumn(
'event', 'text', [
'notnull' => false
]
);
$table->addColumn(
'result', 'text', [
'notnull' => false
]
);
$table->addColumn(
'instance', 'string', [
'length' => 255,
'notnull' => false
]
);
$table->addColumn(
'interface', 'integer', [
'notnull' => true,
'length' => 1,
'default' => 0
]
);
$table->addColumn(
'severity', 'integer', [
'length' => 3,
'notnull' => false
]
);
$table->addColumn(
'retry', 'integer', [
'length' => 3,
'notnull' => false
]
);
$table->addColumn(
'status', 'integer', [
'length' => 3,
'notnull' => false
]
);
$table->addColumn(
'updated', 'datetime', [
'notnull' => false,
]
);
$table->addColumn(
'creation', 'bigint', [
'length' => 14,
'notnull' => false
]
);
$table->addUniqueIndex(['token', 'instance']);
}
/**
* CIRCLES_MEMBERSHIP
*/
if (!$schema->hasTable('circles_membership')) {
$table = $schema->createTable('circles_membership');
$table->addColumn(
'circle_id', 'string', [
'notnull' => true,
'length' => 31,
]
);
$table->addColumn(
'single_id', 'string', [
'notnull' => true,
'length' => 31,
]
);
$table->addColumn(
'level', 'integer', [
'notnull' => true,
'length' => 1,
'unsigned' => true
]
);
$table->addColumn(
'inheritance_first', 'string', [
'notnull' => true,
'length' => 31,
]
);
$table->addColumn(
'inheritance_last', 'string', [
'notnull' => true,
'length' => 31,
]
);
$table->addColumn(
'inheritance_depth', 'integer', [
'notnull' => true,
'length' => 2,
'unsigned' => true
]
);
$table->addColumn(
'inheritance_path', 'text', [
'notnull' => true
]
);
$table->addIndex(['single_id']);
$table->addUniqueIndex(['single_id', 'circle_id']);
$table->addIndex(
['inheritance_first', 'inheritance_last', 'circle_id'], 'circles_membership_ifilci'
);
}
/**
* CIRCLES_TOKEN
*/
if (!$schema->hasTable('circles_token')) {
$table = $schema->createTable('circles_token');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]
);
$table->addColumn(
'share_id', 'integer', [
'notnull' => false,
'length' => 11
]
);
$table->addColumn(
'circle_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'single_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'member_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'token', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'password', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'accepted', 'integer', [
'notnull' => false,
'length' => 1
]
);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['share_id', 'circle_id', 'single_id', 'member_id', 'token'], 'sicisimit');
}
/**
* CIRCLES_MOUNT
*/
if (!$schema->hasTable('circles_mount')) {
$table = $schema->createTable('circles_mount');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]
);
$table->addColumn(
'mount_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'circle_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'single_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'token', 'string', [
'notnull' => false,
'length' => 63
]
);
$table->addColumn(
'parent', 'integer', [
'notnull' => false,
'length' => 11
]
);
$table->addColumn(
'mountpoint', 'text', [
'notnull' => false
]
);
$table->addColumn(
'mountpoint_hash', 'string', [
'notnull' => false,
'length' => 64
]
);
$table->setPrimaryKey(['id']);
$table->addIndex(['circle_id', 'mount_id', 'parent', 'token'], 'circles_mount_cimipt');
}
/**
* CIRCLES_MOUNTPOINT
*/
if (!$schema->hasTable('circles_mountpoint')) {
$table = $schema->createTable('circles_mountpoint');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]
);
$table->addColumn(
'mount_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'single_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'mountpoint', 'text', [
'notnull' => false
]
);
$table->addColumn(
'mountpoint_hash', 'string', [
'notnull' => false,
'length' => 64
]
);
$table->setPrimaryKey(['id']);
$table->addIndex(['mount_id', 'single_id'], 'circles_mountpoint_ms');
}
/**
* CIRCLES_SHARE_LOCK
*/
if (!$schema->hasTable('circles_share_lock')) {
$table = $schema->createTable('circles_share_lock');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
'unsigned' => true,
]
);
$table->addColumn(
'item_id', 'string', [
'notnull' => true,
'length' => 31
]
);
$table->addColumn(
'circle_id', 'string', [
'notnull' => true,
'length' => 31
]
);
$table->addColumn(
'instance', 'string', [
'notnull' => true,
'length' => 127,
]
);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['item_id', 'circle_id']);
}
return $schema;
}
}
@@ -0,0 +1,265 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2021
* @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\Circles\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0022Date20220526113601
*
* @package OCA\Circles\Migration
*/
class Version0022Date20220703115023 extends SimpleMigrationStep {
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('circles_event')) {
$table = $schema->getTable('circles_event');
if (!$table->hasColumn('updated')) {
$table->addColumn(
'updated', 'datetime', [
'notnull' => false,
]
);
}
if (!$table->hasColumn('retry')) {
$table->addColumn(
'retry', 'integer', [
'length' => 3,
'notnull' => false
]
);
}
}
if ($schema->hasTable('circles_member')) {
$table = $schema->getTable('circles_member');
if (!$table->hasColumn('invited_by')) {
$table->addColumn(
'invited_by', 'string', [
'notnull' => false,
'default' => '',
'length' => 31,
]
);
}
}
if ($schema->hasTable('circles_circle')) {
$table = $schema->getTable('circles_circle');
if (!$table->hasColumn('sanitized_name')) {
$table->addColumn(
'sanitized_name', 'string', [
'notnull' => false,
'default' => '',
'length' => 127
]
);
$table->addIndex(['sanitized_name']);
}
}
if ($schema->hasTable('circles_membership')) {
$table = $schema->getTable('circles_membership');
$table->changeColumn(
'circle_id', [
'notnull' => true,
'length' => 31,
]
);
$table->changeColumn(
'single_id', [
'notnull' => true,
'length' => 31,
]
);
$table->changeColumn(
'inheritance_first', [
'notnull' => true,
'length' => 31,
]
);
$table->changeColumn(
'inheritance_last', [
'notnull' => true,
'length' => 31,
]
);
}
if ($schema->hasTable('circles_mount')) {
$table = $schema->getTable('circles_mount');
$table->changeColumn(
'mount_id', [
'notnull' => true,
'length' => 31,
]
);
$table->changeColumn(
'circle_id', [
'notnull' => true,
'length' => 31,
]
);
$table->changeColumn(
'single_id', [
'notnull' => true,
'length' => 31,
]
);
}
if ($schema->hasTable('circles_mountpoint')) {
$table = $schema->getTable('circles_mountpoint');
$table->changeColumn(
'mount_id', [
'notnull' => true,
'length' => 31,
]
);
$table->changeColumn(
'single_id', [
'notnull' => true,
'length' => 31,
]
);
}
if ($schema->hasTable('circles_share_lock')) {
$table = $schema->getTable('circles_share_lock');
$table->changeColumn(
'item_id', [
'notnull' => true,
'length' => 31,
]
);
$table->changeColumn(
'circle_id', [
'notnull' => true,
'length' => 31,
]
);
}
/**
* CIRCLES_TOKEN
*/
if (!$schema->hasTable('circles_token')) {
$table = $schema->createTable('circles_token');
$table->addColumn(
'id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 11,
'unsigned' => true,
]
);
$table->addColumn(
'share_id', 'integer', [
'notnull' => false,
'length' => 11
]
);
$table->addColumn(
'circle_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'single_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'member_id', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'token', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'password', 'string', [
'notnull' => false,
'length' => 31
]
);
$table->addColumn(
'accepted', 'integer', [
'notnull' => false,
'length' => 1
]
);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['share_id', 'circle_id', 'single_id', 'member_id', 'token'], 'sicisimit');
}
return $schema;
}
}
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2022
* @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\Circles\Migration;
use OCP\IDBConnection;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0023Date20211216113101
*
* @package OCA\Circles\Migration
*/
class Version0023Date20211216113101 extends SimpleMigrationStep {
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
}
}
@@ -0,0 +1,106 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2022
* @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\Circles\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Class Version0024Date20220203123901
*
* @package OCA\Circles\Migration
*/
class Version0024Date20220203123901 extends SimpleMigrationStep {
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('circles_token')) {
$table = $schema->getTable('circles_token');
$table->changeColumn(
'password', [
'length' => 127
]
);
}
if ($schema->hasTable('circles_member')) {
$table = $schema->getTable('circles_member');
$table->changeColumn(
'instance',
[
'default' => '',
'notnull' => false,
'length' => 255
]
);
}
if ($schema->hasTable('circles_circle')) {
$table = $schema->getTable('circles_circle');
$table->changeColumn(
'display_name',
[
'notnull' => false,
'default' => '',
'length' => 255
]
);
}
// dropping to be re-created with the right primary keys.
if ($schema->hasTable('circles_event')) {
$schema->dropTable('circles_event');
}
return $schema;
}
}
@@ -0,0 +1,127 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2022
* @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\Circles\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version0024Date20220203123902 extends SimpleMigrationStep {
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('circles_event')) {
$table = $schema->createTable('circles_event');
$table->addColumn(
'token', 'string', [
'notnull' => false,
'length' => 63,
]
);
$table->addColumn(
'event', 'text', [
'notnull' => false
]
);
$table->addColumn(
'result', 'text', [
'notnull' => false
]
);
$table->addColumn(
'instance', 'string', [
'length' => 255,
'notnull' => false
]
);
$table->addColumn(
'interface', 'integer', [
'notnull' => true,
'length' => 1,
'default' => 0
]
);
$table->addColumn(
'severity', 'integer', [
'length' => 3,
'notnull' => false
]
);
$table->addColumn(
'retry', 'integer', [
'length' => 3,
'notnull' => false
]
);
$table->addColumn(
'status', 'integer', [
'length' => 3,
'notnull' => false
]
);
$table->addColumn(
'updated', 'datetime', [
'notnull' => false,
]
);
$table->addColumn(
'creation', 'bigint', [
'length' => 14,
'notnull' => false
]
);
$table->setPrimaryKey(['token', 'instance']);
}
return $schema;
}
}
@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2022
* @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\Circles\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version0024Date20220317190331 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
* @throws SchemaException
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('circles_membership')) {
$table = $schema->getTable('circles_membership');
if (!$table->hasPrimaryKey()) {
$indexes = $table->getIndexes();
// conflict in Oracle with existing unique index, duplicate of primaryKey.
foreach ($indexes as $index) {
if ($index->isUnique()) {
$table->dropIndex($index->getName());
}
}
$table->setPrimaryKey(['single_id', 'circle_id']);
}
}
return $schema;
}
}
@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
/**
* Circles - Bring cloud-users closer together.
*
* 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 2022
* @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\Circles\Migration;
use Closure;
use Doctrine\DBAL\Schema\SchemaException;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Psr\Log\LoggerInterface;
class Version0028Date20230705222601 extends SimpleMigrationStep {
public function __construct(
private LoggerInterface $logger
) {
}
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
try {
$table = $schema->getTable('circles_circle');
if (!$table->hasIndex('dname')) {
$table->addIndex(['display_name'], 'dname');
}
} catch (SchemaException $e) {
$this->logger->warning('Could not find circles_circle', ['exception' => $e]);
}
return $schema;
}
}