mirror of
https://github.com/nextcloud/passman.git
synced 2025-10-14 23:45:50 +08:00
add migration to uniformly change the label column to a length of 2048
Signed-off-by: binsky <timo@binsky.org>
This commit is contained in:
parent
9e52fa0cfc
commit
0599f803fa
1 changed files with 57 additions and 0 deletions
57
lib/Migration/Version020311Date20210831180132.php
Normal file
57
lib/Migration/Version020311Date20210831180132.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Passman\Migration;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
/**
|
||||
* Auto-generated migration step: Please modify to your needs!
|
||||
*/
|
||||
class Version020311Date20210831180132 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
if ($schema->hasTable('passman_credentials')) {
|
||||
$table = $schema->getTable('passman_credentials');
|
||||
$labelColumn = $table->getColumn('label');
|
||||
if ($labelColumn->getLength() < 2048 || $labelColumn->getType() !== Type::getType('string')) {
|
||||
$table->changeColumn('label', [
|
||||
'type' => Type::getType('string'),
|
||||
'length' => 2048
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue