Skip to content

Commit

Permalink
fix: add new db migration for usergroup column
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
  • Loading branch information
enjeck committed Jul 16, 2024
1 parent 7217992 commit d6bc7d8
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions lib/Migration/Version001000Date20240712000000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/** @noinspection PhpUnused */

declare(strict_types=1);

namespace OCA\Tables\Migration;

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

class Version001000Date20240712000000 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper

Check failure on line 21 in lib/Migration/Version001000Date20240712000000.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidReturnType

lib/Migration/Version001000Date20240712000000.php:21:13: InvalidReturnType: Not all code paths of OCA\Tables\Migration\Version001000Date20240712000000::changeSchema end in a return statement, return type OCP\DB\ISchemaWrapper|null expected (see https://psalm.dev/011)

Check failure on line 21 in lib/Migration/Version001000Date20240712000000.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable28

InvalidReturnType

lib/Migration/Version001000Date20240712000000.php:21:13: InvalidReturnType: Not all code paths of OCA\Tables\Migration\Version001000Date20240712000000::changeSchema end in a return statement, return type OCP\DB\ISchemaWrapper|null expected (see https://psalm.dev/011)
* @throws Exception
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if ($schema->hasTable('tables_tables')) {
$table = $schema->getTable('tables_tables');
if (!$table->hasColumn('usergroup_default')) {
$table->addColumn('usergroup_default', Types::TEXT, [
'notnull' => false,
]);
}
if (!$table->hasColumn('usergroup_multiple_items')) {
$table->addColumn('usergroup_multiple_items', Types::BOOLEAN, [
'notnull' => false,
'default' => 0,
]);
}
if (!$table->hasColumn('usergroup_select_users')) {
$table->addColumn('usergroup_select_users', Types::BOOLEAN, [
'notnull' => false,
'default' => 0,
]);
}
if (!$table->hasColumn('usergroup_select_groups')) {
$table->addColumn('usergroup_select_groups', Types::BOOLEAN, [
'notnull' => false,
'default' => 0,
]);
}
if (!$table->hasColumn('show_user_status')) {
$table->addColumn('show_user_status', Types::BOOLEAN, [
'notnull' => false,
'default' => 0,
]);
}
return $schema;
}
}
}

0 comments on commit d6bc7d8

Please sign in to comment.