Strapi table seems corrupted

System Information
  • Strapi Version: 4.11.7
  • Operating System: Ubuntu 22.04 (WSL)
  • Database: sqlite
  • Node Version: v18.16.1
  • NPM Version: 9.5.1
  • Yarn Version: 1.22.19

I can’t create new tables with relations to a currently existing table, and also cannot change foreign keys references to this table from another table.

Creating new tables fails with error TS2345: Argument of type ‘“api::.”’ is not assignable to parameter of type ‘ContentType’.

Any help would be appreciated.

Hi, I have run into the same problem as you.
While I couldn’t find a way to actually resolve it, I found a workaround. You can just add a fallback command to your command to run your strapi project.

Like this:

"scripts": {
        "dev": "strapi develop || (if [ $? -eq 1 ]; then echo 'Yarn failed. Running recovery command...'; rm - 
        rf ./types/ && yarn dev; fi)"

This command activates if strapi fails with exit code 1, then removes the types folder and starts strapi again.

Thanks for your reply. Unfortunately it did not solve the issue. I had the table removed and regenerated the types (I believe your script will do the regeneration). Without manually removing the table and re-adding, the problem persists.