Trouble to : create table ttrss_error_log - Cannot add foreign key constraint

Hi,

I’ trying to upgrade my ttrss from sql version 105 to 130
everything go fine till version 118.

118 version : create table ttrss_error_log
it seems that I’ve trouble with UTF8 but I’m not sure, I follow these 2 URL to try to solve my trouble :

https://mathiasbynens.be/notes/mysql-utf8mb4#utf8-to-utf8mb4

During my different try at last I run by mistake from ttrss/schema/versions/mysql/118.sql :
update ttrss_version set schema_version = 118;

And then when I login again on the web interface I see sql upgrading to 130…

But when I run : php /ttrss-www/ttrss/update.php --feeds
I got this error :
Fatal error: Query INSERT INTO ttrss_error_log
Table ‘ttrss.ttrss_error_log’ doesn’t exist

So I try again to create it :
root@localhost [ttrss]> create table ttrss_error_log(
→ id integer not null auto_increment primary key,
→ owner_uid integer,
→ errno integer not null,
→ errstr text not null,
→ filename text not null,
→ lineno integer not null,
→ context text not null,
→ created_at datetime not null,
→ foreign key (owner_uid) references ttrss_users(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
ERROR 1215 (HY000): Cannot add foreign key constraint

How can I solve this ?
Thanks

Highly suggest you restore from backup. Hoping you have a backup.

Easiest would be to export OPML and import into a fresh install.

Also you’ve not listed any of what you are running, the issue could be your SQL is too old doesn’t support some newer stuff added later on.

switch to feedly, op

This tttrss was running on :

apache24.
php71-7.1.4.
php71-mysqli-7.1.4.
I upgrade mysql from 5.4 to 5.7.

I already try to take a backup, I have a backup of my database up to version ‘117’ but I still have the same issue when I tried to apply schema/versions/mysql/118.sql

I succefully upgrade from 105 to 117 bug hang at 118.
It seems that if I avoid table ttrss_error_log creation the other futher upgrade works.

But it seems that I need table ttrss_error_log.

I think it come for one of my table configuration or encodage or … long shot int … because I can create the whole database with ttrss.ttrss_error_log inside from ttrss/schema/ttrss_schema_mysql.sql

SHOW ENGINE INNODB STATUS; … output


LATEST FOREIGN KEY ERROR

2017-05-11 10:37:45 0x8696d6800 Error in foreign key constraint of table ttrss/ttrss_error_log:
foreign key (owner_uid) references ttrss_users(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=UTF8:
Cannot resolve table name close to:
(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=UTF8

I don’t want to create a new emty database, I would keep my data inside.

your other tables are probably myisam or other such garbage, also the fact that you previously randomly typed commands and shit while not knowing anything certainly didn’t help

idk about others but i’m definitely not getting into your abomination of an install, just export opml and start anew, hopefully even learning a lesson. alternatively wait for some kind soul here to sort out your mess but, you know, i wouldn’t count on it.

fox thanks for your help.

You know the only way to learn is to try and try again.

And I don’t ‘previously randomly typed commands and shit while not knowing anything’…
‘abomination of an install’ … it’s a Mysql as it was in 2013. So …

You are right about my table type.

root@localhost [(none)]> root@localhost [(none)]> SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine = ‘myisam’ AND TABLE_SCHEMA=‘ttrss’;
±------------------------+
| table_name |
±------------------------+
| ttrss_access_keys |
| ttrss_archived_feeds |
| ttrss_enclosures |
| ttrss_entries |
| ttrss_entry_comments |
| ttrss_feed_categories |
| 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_prefs |
| ttrss_prefs_sections |
| ttrss_prefs_types |
| ttrss_sessions |
| ttrss_settings_profiles |
| ttrss_tags |
| ttrss_user_entries |
| ttrss_user_labels2 |
| ttrss_user_prefs |
| ttrss_users |
| ttrss_version |
±------------------------+
27 rows in set (0,01 sec)

then I find hel here : mysql - How to convert all tables from MyISAM into InnoDB? - Stack Overflow
How to convert all tables from MyISAM into InnoDB?

And just do for all my table :
ALTER TABLE table_name ENGINE=Innodb;

and then after a :
mysqldump --databases ttrss > ttrss_Innodb.sql

just in case

I can do :
root@localhost [ttrss]> create table ttrss_error_log(
-> id integer not null auto_increment primary key,
-> owner_uid integer,
-> errno integer not null,
-> errstr text not null,
-> filename text not null,
-> lineno integer not null,
-> context text not null,
-> created_at datetime not null,
-> foreign key (owner_uid) references ttrss_users(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
Query OK, 0 rows affected (0,20 sec)

Thanks you all for your help.

i very much doubt this one liner conversion is going to magically reinstate all the missing constraints that didn’t fire over the years filling your database with garbage data, the fact alone that it worked tells me it didn’t, and your database still has no referential integrity.

since you’re unwilling to do the right thing i.e. wipe everything and reimport your OPML on a functional database schema, i’m going to ask you to not post about any further inevitable problems on this forum. you’re on your own.

at least your thread might serve as an example to others of things not to do, ever.

You can’t just be executing raw sql commands in the hopes to fix this.

I’m going to make this simple for you: your database is corrupt. Period. There is no recovery because you’ve been running for so long under MyISAM and you can’t just switch to InnoDB and think everything is going to work. You’ve already lost the data integrity because you’ve run so long without key constraints. Even if you manage to get this “working” (I use that term loosely) you’re going to encounter weird behaviour using TT-RSS.

Just wipe it all and start will a clean install. It’s not the end of the world, it’s just RSS feeds from web sites not launch codes for national defence.

e: fox beat me by one minute!

i guess the gist here, op, is GTFO and don’t come back until you fix your shit. because what you did instead is literally horrifying to anyone with half a clue.

I don’t run at all without key constraints, it was a 1 day upgrade from a quite old version to new one…
No update of database content between because all services stop.
That key constraints didn’t exist when I was under MyISAM because I was on an old version of ttrss which didn’t require it.

That key constraints didn’t exist when I was under MyISAM because I was on an old version of ttrss which didn’t require it.

i’d like to also ask you to stop lying to my fucking face on my own fucking forum, thank you very much

what actually happened is somehow, despite innodb being explicitly required when mysql support was added (tt-rss was initially postgresql-only), a bunch of people managed to install tt-rss on myisam.

how this happened we’ll probably never know. maybe you and others like you actually modified the schema files, maybe mysql just ignored the type= requirement for some reason (given that mysql approach to foreign keys on myisam is “this statement is silently ignored” this wouldn’t surprise me tbh). i’m not going to point fingers, why this happened is not really important anyway.

now, the problem is, this kind of installation was immediately and pretty much irrevocably broken (tt-rss heavily relied on stuff like foreign keys and cascade deletions from the very beginning).

over the years people came here with the weirdest issues imaginable, and multiple times this was traced back to myisam. and you can’t just convert the table and it’ll work. it won’t. your database is fucked forever and there’s nothing you can do to fix it, other than reconstructing all key relationships manually and cleaning everything that fails integrity checks.

i’m gonna say tho this is the first time when i’m talking to someone who is so adamant at continuing to do the wrong thing as to actually lie to me about shit i wrote. well done.

e: i’m also going to state, again, that in my opinion adding mysql support was the wrong thing to do.

ok no trouble, for me it’s ok now, (I really say for me).
If something goes wrong I can only hit myself about that.
I’m just happy to find some help because you give me some help and I’m just happy with that.

[quote=“JustAMacUser, post:14, topic:165, full:true”]
it’s just RSS feeds from web sites not launch codes for national defence.[/quote]

wait, what? damnit!

(20 character minimum on posts? what?)

and yet, you’re ignoring all of it