From f43f885501aec812de89bb1be7fe814fcd6e8a09 Mon Sep 17 00:00:00 2001 From: JoaoSRaposo Date: Tue, 26 Nov 2024 17:30:00 +0000 Subject: [PATCH] Fix #1019 improving migrations (#89) * FIxing version 0005 migration * Improving query builder variables on previous migrations --- lib/Migration/Version0003Date202401101430.php | 1 - lib/Migration/Version0004Date202410131430.php | 2 ++ lib/Migration/Version0005Date202411081430.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Migration/Version0003Date202401101430.php b/lib/Migration/Version0003Date202401101430.php index 01de0f7..9cb9cfa 100644 --- a/lib/Migration/Version0003Date202401101430.php +++ b/lib/Migration/Version0003Date202401101430.php @@ -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') diff --git a/lib/Migration/Version0004Date202410131430.php b/lib/Migration/Version0004Date202410131430.php index 1500ad9..b36f177 100644 --- a/lib/Migration/Version0004Date202410131430.php +++ b/lib/Migration/Version0004Date202410131430.php @@ -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))) diff --git a/lib/Migration/Version0005Date202411081430.php b/lib/Migration/Version0005Date202411081430.php index 98578ad..0ee9353 100644 --- a/lib/Migration/Version0005Date202411081430.php +++ b/lib/Migration/Version0005Date202411081430.php @@ -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::%'))) @@ -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)))