-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename applicable folder to comply with oracle limitations
Signed-off-by: Robin Appelman <robin@icewind.nl>
- Loading branch information
1 parent
7edb64e
commit 76e7b97
Showing
6 changed files
with
169 additions
and
97 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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,65 @@ | ||
<?php | ||
namespace OCA\GroupFolders\Migration; | ||
|
||
use OCP\DB\ISchemaWrapper; | ||
use OCP\Migration\SimpleMigrationStep; | ||
use OCP\Migration\IOutput; | ||
|
||
class Version102020Date20180806161449 extends SimpleMigrationStep { | ||
/** | ||
* @param IOutput $output | ||
* @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
* @param array $options | ||
* @return null|ISchemaWrapper | ||
* @since 13.0.0 | ||
*/ | ||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { | ||
/** @var ISchemaWrapper $schema */ | ||
$schema = $schemaClosure(); | ||
|
||
if (!$schema->hasTable('group_folders')) { | ||
$table = $schema->createTable('group_folders'); | ||
$table->addColumn('folder_id', 'bigint', [ | ||
'autoincrement' => true, | ||
'notnull' => true, | ||
'length' => 6, | ||
]); | ||
$table->addColumn('mount_point', 'string', [ | ||
'notnull' => true, | ||
'length' => 128, | ||
]); | ||
$table->addColumn('quota', 'bigint', [ | ||
'notnull' => true, | ||
'length' => 6, | ||
'default' => -3, | ||
]); | ||
$table->setPrimaryKey(['folder_id']); | ||
} | ||
|
||
if (!$schema->hasTable('group_folders_groups')) { | ||
$table = $schema->createTable('group_folders_groups'); | ||
$table->addColumn('applicable_id', 'bigint', [ | ||
'autoincrement' => true, | ||
'notnull' => true, | ||
'length' => 6, | ||
]); | ||
$table->addColumn('folder_id', 'bigint', [ | ||
'notnull' => true, | ||
'length' => 6, | ||
]); | ||
$table->addColumn('permissions', 'integer', [ | ||
'notnull' => true, | ||
'length' => 4, | ||
]); | ||
$table->addColumn('group_id', 'string', [ | ||
'notnull' => false, | ||
'length' => 64, | ||
]); | ||
$table->setPrimaryKey(['applicable_id']); | ||
$table->addIndex(['folder_id'], 'group_folder'); | ||
$table->addIndex(['group_id'], 'group_folder_value'); | ||
$table->addUniqueIndex(['folder_id', 'group_id'], 'groups_folder_group'); | ||
} | ||
return $schema; | ||
} | ||
} |
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,96 @@ | ||
<?php | ||
namespace OCA\GroupFolders\Migration; | ||
|
||
use OCP\DB\ISchemaWrapper; | ||
use OCP\IDBConnection; | ||
use OCP\Migration\SimpleMigrationStep; | ||
use OCP\Migration\IOutput; | ||
|
||
class Version103000Date20180806161724 extends SimpleMigrationStep { | ||
/** @var IDBConnection */ | ||
private $connection; | ||
|
||
private $applicableData = []; | ||
|
||
public function __construct(IDBConnection $connection) { | ||
$this->connection = $connection; | ||
} | ||
|
||
public function name(): string { | ||
return 'rename "group_folders_applicable" to "group_folders_groups"'; | ||
} | ||
|
||
public function description(): string { | ||
return 'rename "group_folders_applicable" to fit within oracle limitations'; | ||
} | ||
|
||
public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { | ||
/** @var ISchemaWrapper $schema */ | ||
$schema = $schemaClosure(); | ||
|
||
// copy data | ||
if ($schema->hasTable('group_folders_applicable')) { | ||
$query = $this->connection->getQueryBuilder(); | ||
$query->select(['folder_id', 'permissions', 'group_id']) | ||
->from('group_folders_applicable'); | ||
$result = $query->execute(); | ||
$this->applicableData = $result->fetchAll(\PDO::FETCH_ASSOC); | ||
} | ||
} | ||
|
||
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { | ||
/** @var ISchemaWrapper $schema */ | ||
$schema = $schemaClosure(); | ||
|
||
if (!$schema->hasTable('group_folders_groups')) { | ||
$table = $schema->createTable('group_folders_groups'); | ||
$table->addColumn('applicable_id', 'bigint', [ | ||
'autoincrement' => true, | ||
'notnull' => true, | ||
'length' => 6, | ||
]); | ||
$table->addColumn('folder_id', 'bigint', [ | ||
'notnull' => true, | ||
'length' => 6, | ||
]); | ||
$table->addColumn('permissions', 'integer', [ | ||
'notnull' => true, | ||
'length' => 4, | ||
]); | ||
$table->addColumn('group_id', 'string', [ | ||
'notnull' => false, | ||
'length' => 64, | ||
]); | ||
$table->setPrimaryKey(['applicable_id']); | ||
$table->addIndex(['folder_id'], 'groups_folder'); | ||
$table->addIndex(['group_id'], 'groups_folder_value'); | ||
$table->addUniqueIndex(['folder_id', 'group_id'], 'groups_folder_group'); | ||
} | ||
|
||
if ($schema->hasTable('group_folders_applicable')) { | ||
$schema->dropTable('group_folders_applicable'); | ||
} | ||
|
||
return $schema; | ||
} | ||
|
||
public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { | ||
if (count($this->applicableData)) { | ||
$query = $this->connection->getQueryBuilder(); | ||
$query->insert('group_folders_groups') | ||
->values([ | ||
'folder_id' => $query->createParameter('folder'), | ||
'group_id' => $query->createParameter('group'), | ||
'permissions' => $query->createParameter('permissions') | ||
]); | ||
|
||
foreach($this->applicableData as $data) { | ||
$query->setParameter('folder', $data['folder_id']); | ||
$query->setParameter('group', $data['group_id']); | ||
$query->setParameter('permissions', $data['permissions']); | ||
|
||
$query->execute(); | ||
} | ||
} | ||
} | ||
} |
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