Hi! A couple of days ago I deployed a strapi project on heroku! It seems to look correctly, however, after every couple of hours the project on the server restarts and I’m forced to sign up again and all my data is lost.
I know it resets after deploying, but I haven’t done that, so it’s not the problem.
I am using dyno hobby version, do you think it is an error in my strapi project or the heroku database?
Okay, I believe it resets every day after dyno restarts. How can I solve that issue? Because I believe I can’t just turn off the dyno restarts.
You need to define a database
follow this tutorial:
By default, Strapi uses SQLite (file-based) as its database. So when the dyno restarts, the file goes back to its original state at the time of deployment. Sounds like that’s your scenario.
To solve it, you should migrate to another database such as Postgres. Heroku has a Postgres add-on with a free plan. To set up Postgres for your Strapi instance, check the section “Using Heroku Postgres Addon as Database” on this blog post: Deploy a Strapi API on Heroku in 5 min
I have already installed postgress still facing the same issue.
The same happened on my project yesterday.
- Production env only
- Postgres hosted at Heroku
- Strapi hosted at Heroku
- No environments or database config folders/subfolders
- The issue happened with Strapi V4.5.5, then I updated it to V4.13.6 and it is still happening
The first time it happened I was just adding the first couple data entries in Strapi admin and then it was empty on my next login. I thought I had deleted it by mistake and added a ton of data after that.
The next day, several fields where empty and I was facing lots of errors on frontend due to no data being served.
I couldn’t track what is ‘erasing’ the data, but it seems like when you deploy and update or does any changes on Content-Type Builder and it restarts the application, Strapi simple loses the last row of data added to the database.
It seems to be time related too (I am just guessing, I have no proofs), like, if you deploy or update a content-type with more fields right now, you loose your last 30 minute of data (it’s just an example, I dunno what would be that time window exactly).
I am pretty sure that my configurations are correct. If I found the origin of the issue I’ll be glad to share the cause and a fix.
Will be great if you find an issue. The only time I had similar issue is when I had the wrong configuration, so it was still using sqlite and not my postgress database.
Hi I have maybe a comparable issue I using mariaDB on AWS RDS and I see the correct values but when i rebuild the docker container it delete it from the database. Its in dev mode cause I want to edit stuff.
Is the answer maybe quite simple:
So Strapi saves content-types in file system.
But Herokus filesystem so far I saw is ephimeral (no experience just saw the description).
If the virtual docker volumes get rebuild all that happened before is gone, cause filesystem is resetted.
If even forceMigration is not set to false than it wipe all unknown content-types from database.
I spend one weekend to understand how the docker volumes interact with intellijs remote deployment, strapi and my servers (not heroku). now it works.
Strapi is build on 2 pilars.
1 File system (git) for statures aka content-types
2 data all goes to the DB.
so if you want to update your content-types you do that change localy push it to git and then you restart your container with the latest version in your git repo. what will make it uses the newest version what force migrates the DB to the right version. makes it work correctly. and fixes your force migration issues.
Yes I see this seems to be the only good workflow.
Its is important to know that changing stuff in docker remote is not useful. At least when the file system got not backuped or saved somewhere else.
Correct and your production instances should not be ran in development mode. if that is the cease then file changes can’t be made.