Shopify App Text Reverting Issue

I have created an app with input field, which allows the admin to input text, save it in a database table like prisma SQlite, and display it on the storefront. The app is successfully hosted on Fly.io with the help of this doc Deploy an app to Fly.io but i skip step 3.

The issue is that when I change the text (e.g., from “Hello World” to “My name is Rohan”), it updates correctly on the storefront. However, after some time, the text reverts to the previous value (e.g., back to “Hello World”). Why does this happen, and how can I fix it?

Have you created a volume for your SQLite DB to be stored in? In step 3 it explains that if you don’t create a volume then the saved values will be wiped if the machine is stopped. That may be what is happening here.

2 Likes

hi @Nintron27 ,
Thank you for your reply,
I have read the volume setup documentation, but it doesn’t work in my scenario. I need to create a PostgreSQL database and store my data there. However, I’m encountering an issue when running the command npx prisma migrate dev. The error message I get is:

Error: P1001: Can’t reach database server at ms-postgres-db.flycast:5432
Please make sure your database server is running at ms-postgres-db.flycast:5432.

I have used the database URL in my .env file, and here is the relevant part of my schema.prisma file:

datasource db {
provider = “postgresql”
url = env(“DATABASE_URL”)
}

I also ensured that my app is connected to the PostgreSQL database, and the connection is active (the Fly.io dashboard shows the app as green).

Is there anything specific you’d like me to help with regarding this error?

Are you using a Postgres database in Fly? For example the Fly Postgres offering? I’ll assume yes for now, if so, if you are running npx prisma migrate dev locally it would actually make sense to receive that error as by default Fly Postgres DBs are not available to the open internet (explained here). If that is the case, you have 3 options:

  1. Proxy the DB to your localhost network. These steps are explained here. Then point the Prisma migration to something like localhost:5432
  2. Open your database up to external connections. I would recommend against this, as exposing a DB to the internet is best avoided if it can be. If you do want to though, the steps are explained here. If you do, then you can use ms-postgres-db.fly.dev:5432 instead to connect.
  3. Wireguard (VPN) into your private Fly network. These steps are explained here. (You can continue to use ms-postgres-db.flycast:5432)

If any of my assumptions on your situation are wrong though just let me know!

1 Like

I literally just posted some changes that should have made this easier in the first place: Improved Prisma support - status and plans - it would have created the volume for you if you were using sqlite3, and will set up the database correctly for postgresql.

Any chance you can revert back to where you started and try fly launch again?

2 Likes

hi @Nintron27 ,
I truly appreciate the effort you put into explaining this to me. It has not only solved my doubt but also enhanced my understanding of the topic. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.