diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php index 2e878decb3f96..333d28896ecaa 100644 --- a/apps/dav/composer/composer/autoload_classmap.php +++ b/apps/dav/composer/composer/autoload_classmap.php @@ -340,6 +340,10 @@ 'OCA\\DAV\\Migration\\Version1029Date20231004091403' => $baseDir . '/../lib/Migration/Version1029Date20231004091403.php', 'OCA\\DAV\\Migration\\Version1030Date20240205103243' => $baseDir . '/../lib/Migration/Version1030Date20240205103243.php', 'OCA\\DAV\\Migration\\Version1031Date20240610134258' => $baseDir . '/../lib/Migration/Version1031Date20240610134258.php', + 'OCA\\DAV\\Migration\\Version1032Date20230630084412' => $baseDir . '/../lib/Migration/Version1032Date20230630084412.php', + 'OCA\\DAV\\Migration\\Version1032Date20230630091518' => $baseDir . '/../lib/Migration/Version1032Date20230630091518.php', + 'OCA\\DAV\\Migration\\Version1032Date20230702074215' => $baseDir . '/../lib/Migration/Version1032Date20230702074215.php', + 'OCA\\DAV\\Migration\\Version1032Date20230702074341' => $baseDir . '/../lib/Migration/Version1032Date20230702074341.php', 'OCA\\DAV\\Profiler\\ProfilerPlugin' => $baseDir . '/../lib/Profiler/ProfilerPlugin.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningNode.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php', diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php index 5f43453cda6a7..c70d5e3308ef1 100644 --- a/apps/dav/composer/composer/autoload_static.php +++ b/apps/dav/composer/composer/autoload_static.php @@ -355,6 +355,10 @@ class ComposerStaticInitDAV 'OCA\\DAV\\Migration\\Version1029Date20231004091403' => __DIR__ . '/..' . '/../lib/Migration/Version1029Date20231004091403.php', 'OCA\\DAV\\Migration\\Version1030Date20240205103243' => __DIR__ . '/..' . '/../lib/Migration/Version1030Date20240205103243.php', 'OCA\\DAV\\Migration\\Version1031Date20240610134258' => __DIR__ . '/..' . '/../lib/Migration/Version1031Date20240610134258.php', + 'OCA\\DAV\\Migration\\Version1032Date20230630084412' => __DIR__ . '/..' . '/../lib/Migration/Version1032Date20230630084412.php', + 'OCA\\DAV\\Migration\\Version1032Date20230630091518' => __DIR__ . '/..' . '/../lib/Migration/Version1032Date20230630091518.php', + 'OCA\\DAV\\Migration\\Version1032Date20230702074215' => __DIR__ . '/..' . '/../lib/Migration/Version1032Date20230702074215.php', + 'OCA\\DAV\\Migration\\Version1032Date20230702074341' => __DIR__ . '/..' . '/../lib/Migration/Version1032Date20230702074341.php', 'OCA\\DAV\\Profiler\\ProfilerPlugin' => __DIR__ . '/..' . '/../lib/Profiler/ProfilerPlugin.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningNode.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php', diff --git a/apps/dav/lib/Migration/Version1032Date20230630084412.php b/apps/dav/lib/Migration/Version1032Date20230630084412.php new file mode 100644 index 0000000000000..5a3d63804d9dd --- /dev/null +++ b/apps/dav/lib/Migration/Version1032Date20230630084412.php @@ -0,0 +1,92 @@ + + * + * @author Your name + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\DAV\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; +use Doctrine\DBAL\Types\Type; + +/** + * Cleaning invalid serialized propertyvalues and converting the column type to blob + */ +class Version1028Date20230630084412 extends SimpleMigrationStep { + + public function __construct(protected IDBConnection $connection, protected IConfig $config) { + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + /** + * Cleaning the invalid serialized propertyvalues because of NULL values in a text field + */ + $query = $this->connection->getQueryBuilder(); + $query->delete('properties') + ->where($query->expr()->eq('valuetype', $query->createNamedParameter(3))) + ->executeStatement(); + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + $propertiesTable = $schema->getTable('properties'); + if ($propertiesTable->hasColumn('propertyvaluenew')) { + return null; + } + $propertiesTable->addColumn('propertyvaluenew', Types::TEXT, [ + 'notnull' => false + ]); + + return $schema; + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + $query = $this->connection->getQueryBuilder(); + $query->update('properties') + ->set('propertyvaluenew', 'propertyvalue') + ->executeStatement(); + } +} diff --git a/apps/dav/lib/Migration/Version1032Date20230630091518.php b/apps/dav/lib/Migration/Version1032Date20230630091518.php new file mode 100644 index 0000000000000..472223e0719ce --- /dev/null +++ b/apps/dav/lib/Migration/Version1032Date20230630091518.php @@ -0,0 +1,71 @@ + + * + * @author Your name + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\DAV\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Removing length limit on propertypath column + */ +class Version1028Date20230630091518 extends SimpleMigrationStep { + + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + $propertiesTable = $schema->getTable('properties'); + + $propertiesTable->dropColumn('propertyvalue'); + + return $schema; + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + } +} diff --git a/apps/dav/lib/Migration/Version1032Date20230702074215.php b/apps/dav/lib/Migration/Version1032Date20230702074215.php new file mode 100644 index 0000000000000..e251fb7b23379 --- /dev/null +++ b/apps/dav/lib/Migration/Version1032Date20230702074215.php @@ -0,0 +1,84 @@ + + * + * @author Your name + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\DAV\Migration; + +use Closure; +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; +use OCP\DB\ISchemaWrapper; +use OCP\DB\Types; +use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Auto-generated migration step: Please modify to your needs! + */ +class Version1028Date20230702074215 extends SimpleMigrationStep { + + public function __construct(protected IDBConnection $connection) { + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + $propertiesTable = $schema->getTable('properties'); + $propertiesTable->addColumn('propertyvalue', Types::BLOB, [ + 'notnull' => false + ]); + return $schema; + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) { + $this->connection->executeStatement('UPDATE `*prefix*properties` SET `propertyvalue` = propertyvaluenew::bytea'); + } else { + $query = $this->connection->getQueryBuilder(); + $query->update('properties') + ->set('propertyvalue', 'propertyvaluenew') + ->executeStatement(); + } + } +} diff --git a/apps/dav/lib/Migration/Version1032Date20230702074341.php b/apps/dav/lib/Migration/Version1032Date20230702074341.php new file mode 100644 index 0000000000000..2ba7d6e7e14e7 --- /dev/null +++ b/apps/dav/lib/Migration/Version1032Date20230702074341.php @@ -0,0 +1,71 @@ + + * + * @author Your name + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\DAV\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +/** + * Auto-generated migration step: Please modify to your needs! + */ +class Version1028Date20230702074341 extends SimpleMigrationStep { + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + $propertiesTable = $schema->getTable('properties'); + $propertiesTable->changeColumn('propertyvalue', [ + 'notnull' => true + ]); + $propertiesTable->dropColumn('propertyvaluenew'); + return $schema; + } + + /** + * @param IOutput $output + * @param Closure(): ISchemaWrapper $schemaClosure + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { + } +}