Merge branch 'add-label-column-index' into next

This commit is contained in:
Marcos Zuriaga 2021-08-22 13:27:58 +02:00
commit c81157584a
No known key found for this signature in database
GPG key ID: 7D15585354D072FF

View 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 Version020308Date20210805164128 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');
if (!$table->hasIndex('passman_credential_label_index')) {
$table->changeColumn('label', [
'type' => Type::getType('string'),
'length' => 300
]);
$table->addIndex(['label'], 'passman_credential_label_index');
}
}
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 {
}
}