News: After reset, News App is not working

Created on 5 Oct 2020  路  24Comments  路  Source: nextcloud/news

IMPORTANT

Read and tick the following checkbox after you have created the issue or place an x inside the brackets ;)

Explain the Problem

I reset the Nextcloud News App as it shown in the FAQ

DELETE FROM oc_appconfig WHERE appid = 'news';
DROP TABLE oc_news_items;
DROP TABLE oc_news_feeds;
DROP TABLE oc_news_folders;

After I reinstalled the app, it no longer loads. Only the following error message in the logs:

Error | index | Doctrine\DBAL\Exception\TableNotFoundException:聽An exception occurred while executing 'SELECT COUNT(*) AS size FROM oc_news_items items JOIN oc_news_feeds feeds ON feeds.id = items.feed_id AND feeds.deleted_at = 0 AND feeds.user_id = ? AND items.starred = ? LEFT OUTER JOIN oc_news_folders folders ON folders.id = feeds.folder_id WHERE feeds.folder_id = 0 OR folders.deleted_at = 0' with params ["leo", true]: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_news_items' doesn't exist
-- | -- | --

System Information

  • News app version: 15.0.2
  • Nextcloud version: 20
  • Cron type: cronjob
  • PHP version: 7.4
  • Database and version: Mysql 10.3.23
  • Browser and version: Firefox 81.0.1
  • Distribution and version: Debian buster
support

Most helpful comment

You need to clean the news migration from the oc_migrations table, since the updated structure really can't deal with people editing the database. After that this should report a pending migration, and executing it will recreate the database.

Thanks, that fix it. I still got the Info error but the app is working. I used "DELETE FROM oc_migrations WHERE app = 'news';" for those having this issue.

All 24 comments

Run ./occ maintenance:repair news

maintenance repair don鈥檛 work, see output:

sudo -u www-data ./occ maintenance:repair news

_Too many arguments, expected arguments "command".
maintenance:repair [--include-expensive]_

Try to run just ./occ maintenance:repair (without news)

Yes, of course I've already tried that. It looks like the app won't create new entries on reinstallation after deleting the database. I upgraded Nextcloud from 19.0.4 RC1 to Nextcloud 20. All without any problems. Since the database of the news app was so big, I wanted to reset it as described in the FAQ.

Hmm what you might try in additon to your steps:
Have a look at table oc_jobs. There should be a line called OCA\News\Cron\Updater. Delete it.

Maybe this bring back the News app working?!

I removed this table. Unfortunately it doesn't work. OCA\News\Cron\Updater is newly created and the same error message appears in the Nextcloud log.

You removed the whole table oc_jobs instead of just the line?

Have you tried manually rebuilding the oc_news_... tables?

No, i removed only the Line OCA\News\Cron\Updater. How can i rebuild manually? CREATE TABLE oc_news_items; ? Is this right?

Yeah, more or less - you need to also to rebuild the whole table structure and also the other tables.

Try running a migration of the news app, that should create the tables again.

Try running a migration of the news app, that should create the tables again.

I did that according to the FAQ. The tables were not created. I don't trust myself to create it manually.

Same here. I expected occ app:remove to make a clean uninstall but quickly found out that it's not that simple. Tried to remove those three tables manually as well as the cache and config folders and now fresh installs don't create those tables.

Not sure if it's related but I did migrate to Nextcloud 20 yesterday and the first attempt failed on the news app with some errors regarding constraint violations or duplicate indices (I don't remember clearly, saw similar messages in one of the pull requests and decided to wait it out). It left Nextcloud in the maintenance mode and I had to finish migration manually via occ. Everything seems to work now, except the news app. It started to show me the news I already read and I thought that the easiest and surest way to make sure everything is OK is to export my feeds and to do a clean reinstall. Well, it wasn't a good idea apparently =)

  • App version: 15.0.2
  • Nextcloud version: 20 (official Docker image)
  • Database: PostgreSQL 12 (official Docker image)
  • OS: Ubuntu 20.04 (official ARM build for Raspberry Pi 4)

I can also confirm this issue. I had the cron bug #819 and I though resetting would help. Big mistake, now the news app doesn't work. It won't create the DB entries or the config files. I tried doing a migration and installing the 14 version and it still won't create the tables.
When installing I get the following errors(I removed my user name):
[index] Error: Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT * FROMoc_news_foldersWHEREuser_id= ? ANDdeleted_at` = 0' with params [""]:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_news_folders' doesn't exist at <>

  1. /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 169
    Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... t", Doctrine\DBAL\Dr ... ]})
  2. /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 149
    Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... t")
  3. /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 162
    Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "SELECT * FROM ` ... 0", {1: ""})
  4. /var/www/html/nextcloud/lib/public/AppFramework/Db/Mapper.php line 253
    Doctrine\DBAL\Statement->execute()
  5. /var/www/html/nextcloud/lib/public/AppFramework/Db/Mapper.php line 341
    OCP\AppFramework\Db\Mapper->execute("SELECT * FROM ` ... 0", [""], null, null)
  6. /var/www/html/nextcloud/apps/news/lib/Db/FolderMapper.php line 55
    OCP\AppFramework\Db\Mapper->findEntities("SELECT * FROM ` ... 0", [""])
  7. /var/www/html/nextcloud/apps/news/lib/Service/FolderService.php line 70
    OCA\News\Db\FolderMapper->findAllFromUser("")
  8. /var/www/html/nextcloud/apps/news/lib/Controller/FolderController.php line 59
    OCA\News\Service\FolderService->findAllForUser("")
  9. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 169
    OCA\News\Controller\FolderController->index()
  10. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 100
    OC\AppFramework\Http\Dispatcher->executeController(OCA\News\Controller\FolderController {}, "index")

    1. /var/www/html/nextcloud/lib/private/AppFramework/App.php line 152

      OC\AppFramework\Http\Dispatcher->dispatch(OCA\News\Controller\FolderController {}, "index")

    2. /var/www/html/nextcloud/lib/private/Route/Router.php line 308

      OC\AppFramework\App::main("OCA\News\Controller\FolderController", "index", OC\AppFramework\ ... {}, {action: null,_r ... "})

    3. /var/www/html/nextcloud/lib/base.php line 1009

      OC\Route\Router->match("/apps/news/folders")

    4. /var/www/html/nextcloud/index.php line 37

      OC::handleRequest()

GET /apps/news/folders
from 187.227.169.49 by at 2020-10-04T00:34:15+00:00`

[index] Error: Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing 'SELECT * FROMoc_news_foldersWHEREuser_id= ? ANDdeleted_at` = 0' with params [""]:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_news_folders' doesn't exist at <>

  1. /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 169
    Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException("An exception oc ... t", Doctrine\DBAL\Dr ... ]})
  2. /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 149
    Doctrine\DBAL\DBALException::wrapException(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "An exception oc ... t")
  3. /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 162
    Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Doctrine\DBAL\Driver\PDOMySql\Driver {}, Doctrine\DBAL\Dr ... ]}, "SELECT * FROM ` ... 0", {1: ""})
  4. /var/www/html/nextcloud/lib/public/AppFramework/Db/Mapper.php line 253
    Doctrine\DBAL\Statement->execute()
  5. /var/www/html/nextcloud/lib/public/AppFramework/Db/Mapper.php line 341
    OCP\AppFramework\Db\Mapper->execute("SELECT * FROM ` ... 0", [""], null, null)
  6. /var/www/html/nextcloud/apps/news/lib/Db/FolderMapper.php line 55
    OCP\AppFramework\Db\Mapper->findEntities("SELECT * FROM ` ... 0", [""])
  7. /var/www/html/nextcloud/apps/news/lib/Service/FolderService.php line 70
    OCA\News\Db\FolderMapper->findAllFromUser("")
  8. /var/www/html/nextcloud/apps/news/lib/Controller/FolderController.php line 59
    OCA\News\Service\FolderService->findAllForUser("")
  9. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 169
    OCA\News\Controller\FolderController->index()
  10. /var/www/html/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 100
    OC\AppFramework\Http\Dispatcher->executeController(OCA\News\Controller\FolderController {}, "index")

    1. /var/www/html/nextcloud/lib/private/AppFramework/App.php line 152

      OC\AppFramework\Http\Dispatcher->dispatch(OCA\News\Controller\FolderController {}, "index")

    2. /var/www/html/nextcloud/lib/private/Route/Router.php line 308

      OC\AppFramework\App::main("OCA\News\Controller\FolderController", "index", OC\AppFramework\ ... {}, {action: null,_r ... "})

    3. /var/www/html/nextcloud/lib/base.php line 1009

      OC\Route\Router->match("/apps/news/folders")

    4. /var/www/html/nextcloud/index.php line 37

      OC::handleRequest()

GET /apps/news/folders
from 187.227.169.49 by at 2020-10-04T00:34:15+00:00`

which simply tells me the tables are not created.

I encountered the same issue. I could resolve it by resetting it as described by the reporter and doing the following steps afterwards

  1. Uninstall the news app
  2. Adding a fake installed_version key using "UPDATE oc_appconfig SET configvalue = '7.1.1' WHERE appid = 'news' and configkey = 'installed_version';"
  3. Installing the news app again.

Not sure why that FAQ item was there, it's terrible advice. It doesn't really reset anything as much as completely deleting all data and leaving news in a broken state. You need to figure out how to redo an old (14.2.0) news database migration to fix this. I made a pull request to remove the advice.

Not sure why that FAQ item was there, it's terrible advice. It doesn't really reset anything as much as completely deleting all data and leaving news in a broken state. You need to figure out how to redo an old (14.2.0) news database migration to fix this. I made a pull request to remove the advice.

But what's holding back the database creation? I deleted the app completely and still fails. The only log I get is the app trying to use the database but not creating them when I try to install it again.

What does ./occ migrations:status news report?

What does ./occ migrations:status news report?

In AppLocator.php line 48:

App not found

The app is not installed and after installing from the app store I get:

>> App:                                                news
>> Version Table Name:                                 oc_migrations
>> Migrations Namespace:                               OCA\News\Migration
>> Migrations Directory:                               /var/www/html/nextcloud/apps/news/lib/Migration
>> Previous Version:                                   0
>> Current Version:                                    140200Date20200824201413
>> Next Version:                                       Already at latest migration step
>> Latest Version:                                     140200Date20200824201413
>> Executed Migrations:                                1
>> Executed Unavailable Migrations:                    1
>> Available Migrations:                               1
>> New Migrations:                                     1
>> Pending Migrations:                                 None

I'm also getting this error while installing. I didn't see it before because it's at Info level:

[no app in context] Info: Deprecated event type for OCA\Files::loadAdditionalScripts: Symfony\Component\EventDispatcher\GenericEvent is used

GET /apps/files

And of course the same no database table errors

You need to clean the news migration from the oc_migrations table, since the updated structure really can't deal with people editing the database. After that this should report a pending migration, and executing it will recreate the database.

You need to clean the news migration from the oc_migrations table, since the updated structure really can't deal with people editing the database. After that this should report a pending migration, and executing it will recreate the database.

Thanks, that fix it. I still got the Info error but the app is working. I used "DELETE FROM oc_migrations WHERE app = 'news';" for those having this issue.

We could just add DELETE FROM oc_migrations WHERE app = 'news'; to the existing removal instructions?

You don't really need to do that on normal removals AFAIK.

Can confirm, dropping migrations worked for me. @SMillerDev thanks for the advice!

@wolflarson yea, that would be nice since Nextcloud platform provides no way of doing clean removals: (https://github.com/nextcloud/server/issues/5539). This issue is pretty old and it seems like there is no internal motivation to implement clean removals universally across the platform and this change is also too consequential to expect that the outside contributors would send a patch (hope I'm wrong here). That fact partially justifies the FAQ entry: some people might want to do that for various reasons and there are no cleaner ways to do that.

Some users may want to de-clutter their instances and there is nothing wrong with it. Unfortunately, it's not that easy but at least they have the "manual" option. That's better than no options IMO.

Closing this since it's not actually supported and has a fix

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janumix picture janumix  路  7Comments

BlackIkeEagle picture BlackIkeEagle  路  3Comments

severin-lemaignan picture severin-lemaignan  路  8Comments

criwe picture criwe  路  7Comments

HanFox picture HanFox  路  4Comments