Heroku Deployment loses data (postgreSQL)

System Information
  • Strapi Version: 3.6.5
  • Operating System: MacOS Catalina / Heroku (Linux)
  • Database: PostgreSQL
  • Node Version: 14.0.0
  • NPM Version: 6.14.4


I’m pretty new to developing backend and deploying projects.
I’m a bit confused how the whole thing works. I created a new Strapi Project, using PostgreSQL as DB (so didn’t use the --quickstart flag).
Locally i set up a database, and everything seems to work fine. When navigating the DB via CLI, i can see all data. I have chosen Heroku to deploy my project, and followed the tutorial Heroku Deployment

What i’m confused about:
How and at what step is the data that i create locally, transferred to the remote DB that Heroku creates?
Currently only the DB Scheme gets uploaded, but the data itself does not.
I have done a fair bit of googling, and most problems seems to stem from the fact that people use the --quickstart flag, which creates a SQLite DB locally. But since i created a PostgreSQL DB, i’m confused why it isn’t working.

Any help would be greatly apprectiated

Usually you don’t want your local data (development) to go up into production. If you want your local data into Heroku you’ll need to export your local data and import it there: Importing and Exporting Heroku Postgres Databases | Heroku Dev Center

Hi @flow

I see. I was unaware of this fact.
Am i understanding this correctly then. Then work flow (pun intended) would be as follow:

  1. Locally we only develop the structure that gets saved in json, so just the content-types.
  2. We then deploy the “empty” project (as in, no content).
  3. The content itself gets created on a productive environment, for example staging.

As mentioned in the opening, i’m pretty new to deploying and managing a CMS in general.
I’m assuming that in most cases, it’s not best practice to create the content directly on the production environment. Would this imply that the content would be created on a different environment that has the same setup as production, for example staging. From there, if everything is good, we need to manually export and import the content to the production environment?

Does that sound about right?
Thanks a lot for the link you posted. I really thought i was doing something wrong. I was under the impression, that the data would be deployed automatically when using postgres (or any DB except SQlite). This explains a lot.

Yep! That sounds right. You can actually use one Strapi instance and the save / publish feature so you can have a preview site showing the “saved” content and a production site showing the “published” content.

Very interesting. Would i need to do something like this, in order to access the unpublished content?

Or is there a better way to do this?

It way simpler than this, just enable the “Draft & Publish” feature and you can use the publicated state:

Publication State


This parameter can only be used on models with the Draft & Publish feature activated

Only select entries matching the publication state provided.

Handled states are:

  • live: Return only published entries (default)
  • preview: Return both draft entries & published entries


#Get published articles

GET /articles OR GET /articles?_publicationState=live

#Get both published and draft articles

GET /articles?_publicationState=preview


If you only want to retrieve your draft entries, you can combine the preview mode and the published_at field. GET /articles?_publicationState=preview&published_at_null=true

This is great. Surely this will make things a lot easier to preview before publishing.
Is there any documentation for these arguments? I was able to make it work with a normal rest query, but not with graphql. While the attribute “publicationState” exists (ENUM), “published_at_null” doesn’t seem to get exported to the graphql api.

Either way, thanks so much for all this information. I was a bit sceptical of how strapi works at first, but with these features that i wasn’t aware of, i think it’s much more practicable.

By looking at the docs of the official GraphQL implementation in Strapi, it seems that currently it’s not possible to fetch just the unpublished content. I’m sure this could be added manually to the api somewhere, but i’m not deep enough into Strapi yet. Should the case where i need this come up, i will create a new forum post.