Skip to content

Commit

Permalink
Fix #1019 improving migrations (#89)
Browse files Browse the repository at this point in the history
* FIxing version 0005 migration

* Improving query builder variables on previous migrations
  • Loading branch information
JoaoSRaposo authored Nov 26, 2024
1 parent 7477fc4 commit f43f885
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/Migration/Version0003Date202401101430.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
$mimetype = 'text/markdown';

if (version_compare($currentVersion, '0.5.4', '==')) {
$qb = $this->db->getQueryBuilder();

$updateQb = $this->db->getQueryBuilder();
$updateQb->update('files_swarm')
Expand Down
2 changes: 2 additions & 0 deletions lib/Migration/Version0004Date202410131430.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
$numeric_id = $row['numeric_id'];

// This is assuming we only have one folder with Hejbit Plug (also true on the previous version of the plugin)
$qb = $this->db->getQueryBuilder();
$result = $qb->select('mount_id')
->from('external_mounts')
->where($qb->expr()->eq('storage_backend', $qb->createNamedParameter('files_external_ethswarm')))
->executeQuery();
$mountid = $result->fetchOne();

$qb = $this->db->getQueryBuilder();
$result = $qb->select('value')
->from('external_config','m')
->where($qb->expr()->eq('m.mount_id', $qb->createNamedParameter($mountid)))
Expand Down
4 changes: 2 additions & 2 deletions lib/Migration/Version0005Date202411081430.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op

public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
$gqbNI = $this->db->getQueryBuilder();
$updateQb = $this->db->getQueryBuilder();

// Get all the numeric_id's of the swarm storages

$resultNI = $gqbNI->select('numeric_id', 'id')
->from('storages')
->where($gqbNI->expr()->like('id', $gqbNI->createNamedParameter('ethswarm::%')))
Expand All @@ -82,6 +80,8 @@ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array
$numeric_id = $row['numeric_id'];
$token_id = $row['id'];

$updateQb = $this->db->getQueryBuilder();

$result = $updateQb->update(self::_TABLENAME)
->set('token', $updateQb->createNamedParameter($token_id))
->where($updateQb->expr()->eq('storage', $updateQb->createNamedParameter($numeric_id)))
Expand Down

0 comments on commit f43f885

Please sign in to comment.