Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Migrations')
-rw-r--r--core/Migrations/Version13000Date20170718121200.php105
-rw-r--r--core/Migrations/Version13000Date20170919121250.php13
-rw-r--r--core/Migrations/Version21000Date20201120141228.php65
-rw-r--r--core/Migrations/Version21000Date20201202095923.php75
4 files changed, 252 insertions, 6 deletions
diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php
index 2a47bb52cfc..3acdc3122e3 100644
--- a/core/Migrations/Version13000Date20170718121200.php
+++ b/core/Migrations/Version13000Date20170718121200.php
@@ -31,11 +31,37 @@ namespace OC\Core\Migrations;
use Doctrine\DBAL\Types\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version13000Date20170718121200 extends SimpleMigrationStep {
+ /** @var IDBConnection */
+ private $connection;
+
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ }
+
+ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if (!$schema->hasTable('properties')) {
+ return;
+ }
+ // in case we have a properties table from oc we drop it since we will only migrate
+ // the dav_properties values in the postSchemaChange step
+ $table = $schema->getTable('properties');
+ if ($table->hasColumn('fileid')) {
+ $qb = $this->connection->getQueryBuilder();
+ $qb->delete('properties');
+ $qb->execute();
+ }
+ }
+
+
/**
* @param IOutput $output
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -122,6 +148,15 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$table->addIndex(['root_id'], 'mounts_root_index');
$table->addIndex(['mount_id'], 'mounts_mount_id_index');
$table->addUniqueIndex(['user_id', 'root_id'], 'mounts_user_root_index');
+ } else {
+ $table = $schema->getTable('mounts');
+ $table->addColumn('mount_id', Types::BIGINT, [
+ 'notnull' => false,
+ 'length' => 20,
+ ]);
+ if (!$table->hasIndex('mounts_mount_id_index')) {
+ $table->addIndex(['mount_id'], 'mounts_mount_id_index');
+ }
}
if (!$schema->hasTable('mimetypes')) {
@@ -321,6 +356,27 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$table->setPrimaryKey(['id']);
$table->addIndex(['userid'], 'property_index');
$table->addIndex(['userid', 'propertypath'], 'properties_path_index');
+ } else {
+ $table = $schema->getTable('properties');
+ if ($table->hasColumn('propertytype')) {
+ $table->dropColumn('propertytype');
+ }
+ if ($table->hasColumn('fileid')) {
+ $table->dropColumn('fileid');
+ }
+ if (!$table->hasColumn('propertypath')) {
+ $table->addColumn('propertypath', 'string', [
+ 'notnull' => true,
+ 'length' => 255,
+ ]);
+ }
+ if (!$table->hasColumn('userid')) {
+ $table->addColumn('userid', 'string', [
+ 'notnull' => false,
+ 'length' => 64,
+ 'default' => '',
+ ]);
+ }
}
if (!$schema->hasTable('share')) {
@@ -416,6 +472,14 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$table->addIndex(['parent'], 'parent_index');
$table->addIndex(['uid_owner'], 'owner_index');
$table->addIndex(['uid_initiator'], 'initiator_index');
+ } else {
+ $table = $schema->getTable('share');
+ if (!$table->hasColumn('password')) {
+ $table->addColumn('password', 'string', [
+ 'notnull' => false,
+ 'length' => 255,
+ ]);
+ }
}
if (!$schema->hasTable('jobs')) {
@@ -506,25 +570,25 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
'default' => '',
]);
$table->addColumn('type', 'smallint', [
- 'notnull' => true,
+ 'notnull' => false,
'length' => 2,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('remember', 'smallint', [
- 'notnull' => true,
+ 'notnull' => false,
'length' => 1,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('last_activity', 'integer', [
- 'notnull' => true,
+ 'notnull' => false,
'length' => 4,
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('last_check', 'integer', [
- 'notnull' => true,
+ 'notnull' => false,
'length' => 4,
'default' => 0,
'unsigned' => true,
@@ -535,6 +599,11 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['token'], 'authtoken_token_index');
$table->addIndex(['last_activity'], 'authtoken_last_activity_idx');
+ } else {
+ $table = $schema->getTable('authtoken');
+ $table->addColumn('scope', 'text', [
+ 'notnull' => false,
+ ]);
}
if (!$schema->hasTable('bruteforce_attempts')) {
@@ -937,4 +1006,32 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
}
return $schema;
}
+
+ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+ if (!$schema->hasTable('dav_properties')) {
+ return;
+ }
+ $query = $this->connection->getQueryBuilder();
+ $query->select('*')
+ ->from('dav_properties');
+
+ $insert = $this->connection->getQueryBuilder();
+ $insert->insert('properties')
+ ->setValue('propertypath', $insert->createParameter('propertypath'))
+ ->setValue('propertyname', $insert->createParameter('propertyname'))
+ ->setValue('propertyvalue', $insert->createParameter('propertyvalue'))
+ ->setValue('userid', $insert->createParameter('userid'));
+
+ $result = $query->execute();
+ while ($row = $result->fetch()) {
+ preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match);
+ $insert->setParameter('propertypath', (string) $row['propertypath'])
+ ->setParameter('propertyname', (string) $row['propertyname'])
+ ->setParameter('propertyvalue', (string) $row['propertyvalue'])
+ ->setParameter('userid', (string) ($match[2] ?? ''));
+ $insert->execute();
+ }
+ }
}
diff --git a/core/Migrations/Version13000Date20170919121250.php b/core/Migrations/Version13000Date20170919121250.php
index 330a0141eb8..0667ea87339 100644
--- a/core/Migrations/Version13000Date20170919121250.php
+++ b/core/Migrations/Version13000Date20170919121250.php
@@ -63,8 +63,17 @@ class Version13000Date20170919121250 extends SimpleMigrationStep {
$column->setUnsigned(true);
$column = $table->getColumn('type');
$column->setUnsigned(true);
- $column = $table->getColumn('remember');
- $column->setUnsigned(true);
+ if ($table->hasColumn('remember')) {
+ $column = $table->getColumn('remember');
+ $column->setUnsigned(true);
+ } else {
+ $table->addColumn('remember', 'smallint', [
+ 'notnull' => false,
+ 'length' => 1,
+ 'default' => 0,
+ 'unsigned' => true,
+ ]);
+ }
$column = $table->getColumn('last_activity');
$column->setUnsigned(true);
$column = $table->getColumn('last_check');
diff --git a/core/Migrations/Version21000Date20201120141228.php b/core/Migrations/Version21000Date20201120141228.php
new file mode 100644
index 00000000000..844679b8d95
--- /dev/null
+++ b/core/Migrations/Version21000Date20201120141228.php
@@ -0,0 +1,65 @@
+<?php
+
+declare(strict_types=1);
+
+namespace OC\Core\Migrations;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version21000Date20201120141228 extends SimpleMigrationStep {
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if ($schema->hasTable('authtoken')) {
+ $table = $schema->getTable('authtoken');
+ $loginNameColumn = $table->getColumn('login_name');
+ if ($loginNameColumn->getLength() !== 255) {
+ $loginNameColumn->setLength(255);
+ }
+ $table->changeColumn('type', [
+ 'notnull' => false,
+ ]);
+ $table->changeColumn('remember', [
+ 'notnull' => false,
+ ]);
+ $table->changeColumn('last_activity', [
+ 'notnull' => false,
+ ]);
+ $table->changeColumn('last_check', [
+ 'notnull' => false,
+ ]);
+ }
+
+ if ($schema->hasTable('dav_job_status')) {
+ $schema->dropTable('dav_job_status');
+ }
+
+ if ($schema->hasTable('systemtag')) {
+ $table = $schema->getTable('systemtag');
+ if ($table->hasColumn('systemtag')) {
+ $table->dropColumn('assignable');
+ }
+ }
+
+ if ($schema->hasTable('share')) {
+ $table = $schema->getTable('share');
+ if ($table->hasColumn('attributes')) {
+ $table->dropColumn('attributes');
+ }
+ }
+
+ if ($schema->hasTable('jobs')) {
+ $table = $schema->getTable('jobs');
+ $table->changeColumn('execution_duration', [
+ 'notnull' => false,
+ 'default' => 0,
+ ]);
+ }
+
+ return $schema;
+ }
+}
diff --git a/core/Migrations/Version21000Date20201202095923.php b/core/Migrations/Version21000Date20201202095923.php
new file mode 100644
index 00000000000..6433d8c9b7a
--- /dev/null
+++ b/core/Migrations/Version21000Date20201202095923.php
@@ -0,0 +1,75 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2020 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 OC\Core\Migrations;
+
+use Closure;
+use Doctrine\DBAL\Types\Types;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version21000Date20201202095923 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): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ if (!$schema->hasTable('accounts_data')) {
+ $table = $schema->createTable('accounts_data');
+ $table->addColumn('id', Types::BIGINT, [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ 'length' => 20,
+ ]);
+ $table->addColumn('uid', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ ]);
+ $table->addColumn('name', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 64,
+ ]);
+ $table->addColumn('value', Types::STRING, [
+ 'notnull' => false,
+ 'length' => 255,
+ 'default' => '',
+ ]);
+ $table->setPrimaryKey(['id']);
+ $table->addIndex(['uid'], 'accounts_data_uid');
+ $table->addIndex(['name'], 'accounts_data_name');
+ $table->addIndex(['value'], 'accounts_data_value');
+
+ return $schema;
+ }
+
+ return null;
+ }
+}