Strapi database got corrupted / application keeps overwriting it

System Information
  • Strapi Version: 4.8.1
  • Operating System: Windows
  • Database: PostgreSQL
  • Node Version: 16.19.1
  • NPM Version: 8.19.1

Hey everyone!

A few months ago I was working on adding some new fields/components to our Strapi application. In the meantime, I had to make a quick fix based on the main branch so I switched to it, made the changes, and switched back to the branch I was working on.

It seems that those actions somehow broke the database schema. Since that time Strapi application regularly flushes all the changes related to the branch with new fields/components.

One thing we noticed is that the strapi_database_schema table from the backup (that has all the contents but is being overwritten/broken shortly after the application starts) has two rows with ID: 1 and ID: 199. The same table after the application starts has just one row with ID: 200. The number of tables in general also changes from 85 to 56.

Has anyone encountered a similar problem? Is there anything we can do to keep our progress/content in the database?

Hey Konrad,

I’ve recently had a similar issue. I’m on v4.9.0

Using strapi on the backend with AWS EC2, RDS, S3. Which feeds a nextjs/vercel repo.

It happened after I added another strapi repo to EC2 and was adjusting my NGINX config and restarted the server a bunch of times.

The next day my strapi site had no data in it. I manually checked the postgres db and saw almost everything was gone. Only thing left was the file entires and an entry in the global_components table. I only had about 5 entries so not a big deal. But what happened?

I’m relatively new to strapi and would like to use it for some production work so I’d like to avoid these kinds of issues.

In the meantime, I’ll make sure logs are verbose and perform regular backups…? Any other tips for avoiding this or fixing this?