Wallabag: Error upgrading from 2.2.3 to 2.3.0

Created on 12 Dec 2017  路  4Comments  路  Source: wallabag/wallabag

Issue details

Migration 20170719231144 failed during Execution. Error An exception occurred while executing '
UPDATE wallabag_entry_tag
SET tag_id = 2074
WHERE tag_id IN (2075)
AND entry_id NOT IN (
SELECT entry_id
FROM wallabag_entry_tag
WHERE tag_id = 2074
)':

SQLSTATE[HY000]: General error: 1093 Table 'wallabag_entry_tag' is specified twice, both as a target for 'UPDATE' and as a separate source for data

Environment

  • wallabag version (or git revision) that exhibits the issue: 2.3 (upgrade to)
  • How did you install wallabag? Via git clone or by downloading the package?
  • Last wallabag version that did not exhibit the issue (if applicable): 2.2.3
  • php version: 7.0.22
  • OS: ubuntu 16.04 LTS
  • type of hosting (shared or dedicated): dedicated
  • which storage system you choose at install (SQLite, MySQL/MariaDB or PostgreSQL): MariaDB

Steps to reproduce/test case

make update

Solution

Should be to replace in app/DoctrineMigrations/Version20170719231144.php

            $this->addSql('
                UPDATE ' . $this->getTable('entry_tag') . '
                SET    tag_id = ' . $newId . '
                WHERE  tag_id IN (' . implode(',', $ids) . ')
                    AND entry_id NOT IN (
                       SELECT entry_id
                       FROM ' . $this->getTable('entry_tag') . '
                       WHERE tag_id = ' . $newId . '
                    )'
            );

By something like :

         $this->addSql('
                UPDATE ' . $this->getTable('entry_tag') . '
                SET    tag_id = ' . $newId . '
                WHERE  tag_id IN (' . implode(',', $ids) . ')
                    AND entry_id NOT IN (
                       SELECT entry_id
                       FROM (select * from ' . $this->getTable('entry_tag') . ') AS mytablename
                       WHERE tag_id = ' . $newId . '
                    )'
            );

Because I think it's a MariaDB SQL syntax error

Source : https://stackoverflow.com/questions/44970574/table-is-specified-twice-both-as-a-target-for-update-and-as-a-separate-source

Can I modify myself this file, run it alone and update the "migration_versions" table ?

Bug

Most helpful comment

I did modify the file as indicated by @FrenchHope and ran

php bin/console doctrine:migrations:migrate --no-interaction --env=prod
php bin/console cache:clear --env=prod

as indicated in https://github.com/wallabag/wallabag/blob/master/scripts/update.sh#L19

It ran smoothly. Anyway, a patch is needed to make it easy for everyone.

All 4 comments

I did modify the file as indicated by @FrenchHope and ran

php bin/console doctrine:migrations:migrate --no-interaction --env=prod
php bin/console cache:clear --env=prod

as indicated in https://github.com/wallabag/wallabag/blob/master/scripts/update.sh#L19

It ran smoothly. Anyway, a patch is needed to make it easy for everyone.

Could you try this, instead:

$this->addSql('
                UPDATE ' . $this->getTable('entry_tag') . '
                SET    tag_id = ' . $newId . '
                WHERE  tag_id IN (' . implode(',', $ids) . ')
                    AND entry_id NOT IN (
                       SELECT entry_id
                       FROM ' . $this->getTable('entry_tag') . ' AS _entry_tag
                       WHERE tag_id = ' . $newId . '
                    )'
            );

Thank you @Chouchen , it worked.

@Kdecherf it didn't worked on my configuration, but :

FROM (select * from ' . $this->getTable('entry_tag') . ') AS _entry_tag

instead of

FROM ' . $this->getTable('entry_tag') . ' AS _entry_tag

worked

Same for me, the solution @Kdecherf worked with the fix of @FrenchHope.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

n00b12345 picture n00b12345  路  6Comments

erixtekila picture erixtekila  路  7Comments

valvin1 picture valvin1  路  4Comments

nicosomb picture nicosomb  路  7Comments

ANAT01 picture ANAT01  路  7Comments