sqlite3 foreign keys ignored
I was partially able to reproduce your bug when having PRAGMA foreign_keys = ON;, but setting the domain column in the domains table as PRIMARY KEY removed any problem in my case. (Still keep the pragma on).