зеркало из https://github.com/nextcloud/cookbook.git
Update schema to cope well with shared recipes
Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Родитель
cc0908e75a
Коммит
b85f4af5d8
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Cookbook\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
/**
|
||||
* Auto-generated migration step: Please modify to your needs!
|
||||
*/
|
||||
class Version000000Date20210701093123 extends SimpleMigrationStep {
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
$namesTable = $schema->getTable('cookbook_names');
|
||||
if ($namesTable->hasPrimaryKey()) {
|
||||
$namesTable->dropPrimaryKey();
|
||||
}
|
||||
if (! $namesTable->hasIndex('names_recipe_idx')) {
|
||||
$namesTable->addUniqueIndex([
|
||||
'recipe_id',
|
||||
'user_id'
|
||||
], 'names_recipe_idx');
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
}
|
Загрузка…
Ссылка в новой задаче