-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add new db migration for usergroup column
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / static-psalm-analysis dev-masterInvalidReturnType
Check failure on line 21 in lib/Migration/Version001000Date20240712000000.php GitHub Actions / static-psalm-analysis dev-stable28InvalidReturnType
|
||
* @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; | ||
} | ||
} | ||
} |