Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
  • Loading branch information
tcitworld committed Oct 15, 2024
1 parent c4be207 commit e06a61d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions apps/dav/lib/Migration/Version1032Date20230630084412.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
/**
* Cleaning the invalid serialized propertyvalues because of NULL values in a text field
*/
var_dump("Version1028Date20230630084412 pre change schema");
$query = $this->connection->getQueryBuilder();
$query->delete('properties')
->where($query->expr()->eq('valuetype', $query->createNamedParameter(3)))
Expand All @@ -67,6 +68,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
var_dump("Version1028Date20230630084412 change schema");
$propertiesTable = $schema->getTable('properties');
if ($propertiesTable->hasColumn('propertyvaluenew')) {
return null;
Expand All @@ -84,6 +86,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
var_dump("Version1028Date20230630084412 post change schema");
$query = $this->connection->getQueryBuilder();
$query->update('properties')
->set('propertyvaluenew', 'propertyvalue')
Expand Down
4 changes: 1 addition & 3 deletions apps/dav/lib/Migration/Version1032Date20230630091518.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* Removing length limit on propertypath column
*/
class Version1028Date20230630091518 extends SimpleMigrationStep {


Expand All @@ -54,6 +51,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
var_dump("Version1028Date20230630091518 change schema");
$propertiesTable = $schema->getTable('properties');

$propertiesTable->dropColumn('propertyvalue');
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/Migration/Version1032Date20230702074215.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
*/
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');
$this->connection->executeStatement('UPDATE `*prefix*properties` SET `propertyvalue` = `propertyvaluenew` USING propertyvalue::bytea');
} else {
var_dump("Version1028Date20230702074215 post schema");
$query = $this->connection->getQueryBuilder();
$query->update('properties')
->set('propertyvalue', 'propertyvaluenew')
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/Migration/Version1032Date20230702074341.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
var_dump("Version1028Date20230702074341 change schema");
$schema = $schemaClosure();
$propertiesTable = $schema->getTable('properties');
$propertiesTable->changeColumn('propertyvalue', [
Expand Down
11 changes: 9 additions & 2 deletions apps/dav/lib/Migration/Version1032Date20230702074342.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,26 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
var_dump("Version1028Date20230702074342 change schema");
$schema = $schemaClosure();
$propertiesTable = $schema->getTable('properties');

// Indexes can't be added on columns with such length, so we drop them here before recreating them
$propertiesTable->dropIndex('properties_path_index');
$propertiesTable->dropIndex('properties_pathonly_index');

$propertyValueColumn = $propertiesTable->getColumn('propertypath');
$propertyValueColumn->setLength(4000);
$propertiesTable->changeColumn('propertypath', [
'length' => 4000
]);
// $propertyValueColumn = $propertiesTable->getColumn('propertypath');
// var_dump($propertyValueColumn->getType());
// $propertyValueColumn->setLength(4000);

$propertiesTable->addIndex(['userid', 'propertypath'], 'properties_path_idx_prefix', [], ['lengths' => [null, 64]]);
$propertiesTable->addIndex(['propertypath'], 'properties_pathonly_idx_prefix', [], ['lengths' => [64]]);



return $schema;
}

Expand Down

0 comments on commit e06a61d

Please sign in to comment.