We had to drop a significant work and recreate the table from scratch
That's a pity - but really: everybody always states that the $rowid$ column is internal and direct access is unsupported. Trying to do it anyway is a bug.
For ID generation there exist other options like the IDENTITY column or sequences.