Skip to content

Commit

Permalink
Merge branch 'development' into feature/DIMOC-230/catalogi-org-option
Browse files Browse the repository at this point in the history
  • Loading branch information
RalkeyOfficial committed Aug 8, 2024
2 parents ec4aedc + bdcb133 commit acf982b
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions lib/Migration/Version6Date20240808115347.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\OpenCatalogi\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
* FIXME Auto-generated migration step: Please modify to your needs!
*/
class Version6Date20240808115347 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();

if($schema->hasTable(tableName: 'catalogi') === true) {
$table = $schema->getTable(tableName: 'catalogi');

if($table->hasColumn(name: 'organization') === true) {
$column = $table->dropColumn('organization');
}
if($table->hasColumn(name: 'organisation') === false) {
$table->addColumn(
name: 'organisation',
typeName: Types::STRING,
options: [
'notNull' => false,
'default' => null
]);
}

}

return $schema;
}

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
}
}

0 comments on commit acf982b

Please sign in to comment.