[Solved] Base table or view not found: 1146 Table 'ttrss.ttrss_user_labels2' doesn't exist

Describe the problem you’re having:
Since my upgrade to ttrss version efae0858183d1d71604ff3c9882c8e30dba3b336 the system is missing the table ttrss.ttrss_user_labels2. I can’t remember which version I had before :-/ But it was working before.

I checked my existing tables and yes this specific table is missing. I have this tables:
---------------------------------------+
| Tables_in_ttrss |
±--------------------------------------+
| ttrss_access_keys |
| ttrss_archived_feeds |
| ttrss_cat_counters_cache |
| ttrss_counters_cache |
| ttrss_enclosures |
| ttrss_entries |
| ttrss_entry_comments |
| ttrss_error_log |
| ttrss_feed_categories |
| ttrss_feedbrowser_cache |
| ttrss_feeds |
| ttrss_filter_actions |
| ttrss_filter_types |
| ttrss_filters |
| ttrss_filters2 |
| ttrss_filters2_actions |
| ttrss_filters2_rules |
| ttrss_labels2 |
| ttrss_linked_feeds |
| ttrss_linked_instances |
| ttrss_plugin_af_sort_bayes_categories |
| ttrss_plugin_af_sort_bayes_references |
| ttrss_plugin_af_sort_bayes_wordfreqs |
| ttrss_plugin_storage |
| ttrss_prefs |
| ttrss_prefs_sections |
| ttrss_prefs_types |
| ttrss_sessions |
| ttrss_settings_profiles |
| ttrss_tags |
| ttrss_user_entries |
| ttrss_user_prefs |
| ttrss_users |
| ttrss_version |
±--------------------------------------+

I gathered the information about the missing table via prefs.php -> system:
“SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘ttrss.ttrss_user_labels2’ doesn’t exist”

ttrss is not asking if it should update the db schema after login. It just hangs at 80% and the browser console informs me about a http 500 error.

Also
./update.php --update-schema
gives me:
[16:38:46/11114] Lock: update.lock
[16:38:46/11114] checking for updates (mysql)…
[16:38:46/11114] update not required.

Could you tell me if this table is needed in the current version and maybe someone has a clue how to recreate the table if needed? thx

tt-rss version (including git commit id):
efae0858183d1d71604ff3c9882c8e30dba3b336

Platform (i.e. Linux distro, PHP, PostgreSQL, etc) versions:
Debian Jessie
PHP 5.6.38-0+deb8u1
mysql Ver 14.14 Distrib 5.5.62, for debian-linux-gnu (x86_64) using readline 6.3

yes, the table is needed.

if all else fails you can get relevant create table statement from mysql schema file (in schema/) and run it using mysql shell or phpmyadmin. it really should be self explanatory, just open the file in text editor and search for ttrss_user_labels2.

sorry for the delay, kinda missed your post there.

Thx for the fast reply! I will try to do that.
Does it make sense to try to find out what is causing that problem?

Okay, but do you have a general idea how old it was? Because if it were really old your version might not have had that table. TT-RSS shouldn’t let you run it without first updating the database structure (as you know), but perhaps if your version was really old something broke along the way.

Always. But it could be anything, especially if you’ve been running for years. Maybe you manually changed something at some point and it broke. Maybe there was a bug in the code that broke it. Who knows.

If you’re on the latest version as of my writing this (cd0a39ea4c) you can run the following after connecting to the database:

drop table if exists ttrss_user_labels2;
create table ttrss_user_labels2 (label_id integer not null,
	article_id integer not null,
	foreign key (label_id) references ttrss_labels2(id) ON DELETE CASCADE,
	foreign key (article_id) references ttrss_entries(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;

I wouldn’t just import the whole schema file since that will drop all the tables in your database and you’ll lose everything you have.

As always, backup your database before proceeding.

Thx for providing the sql statements. They worked as a charm. It seems the web gui is working as is the android app.
Sadly I can’t remember how old my ttrss version was. Something around 6 month or a year? But I will try to be more attentive during my next upgrade so I can provide more information next time if something bad happens.

Thx for the great support you all! My problem is solved :wink: