Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add backend for new user/group column #1090

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
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-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)

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)
* @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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
return null;

}
}
Loading