mirror of
https://github.com/verdigado/groupfolder_tags.git
synced 2024-11-21 12:47:27 +01:00
added tags database table
This commit is contained in:
parent
aae5a4d5f7
commit
ec78c4a488
1 changed files with 57 additions and 0 deletions
57
lib/Migration/Version000000Date20240731110600.php
Normal file
57
lib/Migration/Version000000Date20240731110600.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\GroupfolderTags\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\Types;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
use OCP\Migration\IOutput;
|
||||
|
||||
class Version000000Date20240731110600 extends SimpleMigrationStep {
|
||||
public const GROUP_FOLDERS_TABLE = "group_folders";
|
||||
public const GROUP_FOLDER_TAGS_TABLE = "groupfolder_tags";
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
if (!$schema->hasTable(self::GROUP_FOLDER_TAGS_TABLE)) {
|
||||
$table = $schema->createTable(self::GROUP_FOLDER_TAGS_TABLE);
|
||||
$table->addColumn('group_folder_id', Types::BIGINT, [
|
||||
'notnull' => true,
|
||||
'length' => 20,
|
||||
]);
|
||||
$table->addColumn('tag_key', Types::STRING, [
|
||||
'notnull' => true,
|
||||
'length' => 50,
|
||||
]);
|
||||
$table->addColumn('tag_value', Types::STRING, [
|
||||
'notnull' => true,
|
||||
'length' => 200,
|
||||
]);
|
||||
$table->addColumn('last_updated_timestamp', Types::BIGINT, [
|
||||
'notnull' => true,
|
||||
]);
|
||||
|
||||
$table->setPrimaryKey(['group_folder_id', 'tag_key']);
|
||||
$table->addIndex(['group_folder_id'], 'groupfolder_tags_group_folder_id_index');
|
||||
$table->addForeignKeyConstraint(
|
||||
$schema->getTable(self::GROUP_FOLDERS_TABLE),
|
||||
['group_folder_id'],
|
||||
['folder_id'],
|
||||
['onDelete' => 'CASCADE'],
|
||||
'groupfolder_tags_group_folder_id_fk');
|
||||
}
|
||||
|
||||
return $schema;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue