Skip to content

Commit

Permalink
Comment legacy file_metadata table migrations
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Dec 13, 2023
1 parent 0fcc884 commit ba44843
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 46 deletions.
36 changes: 18 additions & 18 deletions core/Migrations/Version24000Date20220404230027.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ class Version24000Date20220404230027 extends SimpleMigrationStep {
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
// /** @var ISchemaWrapper $schema */
// $schema = $schemaClosure();

if (!$schema->hasTable('file_metadata')) {
$table = $schema->createTable('file_metadata');
$table->addColumn('id', Types::BIGINT, [
'notnull' => true,
]);
$table->addColumn('group_name', Types::STRING, [
'notnull' => true,
'length' => 50,
]);
$table->addColumn('value', Types::TEXT, [
'notnull' => false,
'default' => '',
]);
$table->setPrimaryKey(['id', 'group_name'], 'file_metadata_idx');
// if (!$schema->hasTable('file_metadata')) {
// $table = $schema->createTable('file_metadata');
// $table->addColumn('id', Types::BIGINT, [
// 'notnull' => true,
// ]);
// $table->addColumn('group_name', Types::STRING, [
// 'notnull' => true,
// 'length' => 50,
// ]);
// $table->addColumn('value', Types::TEXT, [
// 'notnull' => false,
// 'default' => '',
// ]);
// $table->setPrimaryKey(['id', 'group_name'], 'file_metadata_idx');

return $schema;
}
// return $schema;
// }

return null;
}
Expand Down
43 changes: 22 additions & 21 deletions core/Migrations/Version27000Date20230309104325.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ public function __construct(
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$metadataTable = $schema->getTable('file_metadata');
// /** @var ISchemaWrapper $schema */
// $schema = $schemaClosure();
// $metadataTable = $schema->getTable('file_metadata');

if ($metadataTable->hasColumn('value')) {
return null;
}
// if ($metadataTable->hasColumn('value')) {
// return null;
// }

$metadataTable->addColumn('value', Types::TEXT, [
'notnull' => false,
'default' => '',
]);
return $schema;
// $metadataTable->addColumn('value', Types::TEXT, [
// 'notnull' => false,
// 'default' => '',
// ]);
// return $schema;
return null;
}


Expand All @@ -74,17 +75,17 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$metadataTable = $schema->getTable('file_metadata');
// $schema = $schemaClosure();
// $metadataTable = $schema->getTable('file_metadata');

if (!$metadataTable->hasColumn('metadata')) {
return;
}
// if (!$metadataTable->hasColumn('metadata')) {
// return;
// }

$this->connection
->getQueryBuilder()
->update('file_metadata')
->set('value', 'metadata')
->executeStatement();
// $this->connection
// ->getQueryBuilder()
// ->update('file_metadata')
// ->set('value', 'metadata')
// ->executeStatement();
}
}
14 changes: 7 additions & 7 deletions core/Migrations/Version27000Date20230309104802.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class Version27000Date20230309104802 extends SimpleMigrationStep {
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$metadataTable = $schema->getTable('file_metadata');
// /** @var ISchemaWrapper $schema */
// $schema = $schemaClosure();
// $metadataTable = $schema->getTable('file_metadata');

if ($metadataTable->hasColumn('metadata')) {
$metadataTable->dropColumn('metadata');
return $schema;
}
// if ($metadataTable->hasColumn('metadata')) {
// $metadataTable->dropColumn('metadata');
// return $schema;
// }

return null;
}
Expand Down

0 comments on commit ba44843

Please sign in to comment.