# Moving to a monorepo | LiteFS and Prisma

**URL:** <https://community.fly.io/t/moving-to-a-monorepo-litefs-and-prisma/23973>\
**Category:** JavaScript\
**Tags:** litefs, login-only\
**Created:** [February 19, 2025, 6:58pm UTC](https://community.fly.io/t/moving-to-a-monorepo-litefs-and-prisma/23973 "2025-02-19T18:58:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spedix](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/spedix/32/48136_2.png) [@Spedix](https://community.fly.io/u/Spedix)\
**Post date:** [February 19, 2025, 6:58pm UTC](https://community.fly.io/t/moving-to-a-monorepo-litefs-and-prisma/23973/1 "2025-02-19T18:58:04Z")

</div>

Hi everyone,

In the past my app used the following template [Epic Stack](https://github.com/epicweb-dev/epic-stack) with the following essential config for the deployment to [Fly.io](http://Fly.io)

[Dockerfile](https://github.com/epicweb-dev/epic-stack/blob/main/other/Dockerfile)  
[fly.toml](https://github.com/epicweb-dev/epic-stack/blob/main/fly.toml)  
[litefs](https://github.com/epicweb-dev/epic-stack/blob/main/other/litefs.yml)

I SSH’ed into the production VM (before the monorepo setup) and I saw that somehow a data.db file gets created in the ./prisma folder at the root.

While I was moving the app into a monorepo I was asking myself: how and why? I had quite some problems and struggles make a monorepo work and in no way I got a data.db inside the Prisma folder generated. I had to change a bunch of files and ENV variables in order to get a connection.

What I have done now is:

fly.toml

```auto
[mounts]
source = "litefs"
destination = "/var/lib/litefs"

[build]
dockerfile = "/other/Dockerfile"
ignorefile = "/other/Dockerfile.dockerignore"

```

litefs.yml

```yml
fuse:
  dir: '${LITEFS_DIR}'
data:
  dir: '/var/lib/litefs'

exec:
  - cmd: npx prisma migrate deploy --schema ./apps/sitenu/prisma/schema.prisma
    if-candidate: true

  # Main database WAL
  - cmd: sqlite3 /litefs/data/sqlite.db "PRAGMA journal_mode = WAL;"
    if-candidate: true

  # Cache database WAL
  - cmd: sqlite3 /litefs/data/cache.db "PRAGMA journal_mode = WAL;"
    if-candidate: true

  - cmd: npm start --prefix apps/sitenu

```

[Dockerfile](https://gist.github.com/DennisKraaijeveld/bc59988cc6fc7302c3867aa2787bee27)

I had to change the ENV to:

DATABASE\_URL: file:/litefs/data/sqlite.db  
DATABASE\_PATH: /litefs/data/sqlite.db  
CACHE\_DATABASE\_PATH: /litefs/data/cache.db  
LITEFS\_DIR: /litefs/data

While I had:  
DATABASE\_URL: file:/litefs/data/sqlite.db  
DATABASE\_PATH: ./prisma/data.db  
CACHE\_DATABASE\_PATH: ./other/cache.db  
LITEFS\_DIR: /litefs/data

Is this setup correct or did I miss something in order to get the data.db file get created in the prisma folder? I should note that first when I ssh’ed into the VM my whole project was available within #app. Now with the monorepo the actual app is att #app/apps/projectname

---

<div class="post-metadata">

**Author:** ![mayailurus](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/mayailurus/32/17593_2.png) [@mayailurus](https://community.fly.io/u/mayailurus)\
**Post date:** [February 19, 2025, 11:08pm UTC](https://community.fly.io/t/moving-to-a-monorepo-litefs-and-prisma/23973/2 "2025-02-19T23:08:42Z")

</div>

> [@Spedix](#):
>
> DATABASE\_URL: file:/litefs/data/sqlite.db  
> DATABASE\_PATH: /litefs/data/sqlite.db  
> CACHE\_DATABASE\_PATH: /litefs/data/cache.db  
> LITEFS\_DIR: /litefs/data

Hi… This version looks correct, although I don’t know the details of Epic Stack, per se. The app should always access the database via the FUSE mount, which your `litefs.yml` does declare to be `$LITEFS_DIR`. Generally, I would use absolute paths (i.e., `/something` rather than `./something`) for environment variables such as these, since the working directory (the initial `.` in `./prisma/data.db`) that the app actually runs in is not always easy to deduce.

Quite possibly I’ve misunderstood your overall question, though… Are things working now, and you’re just wondering why it was previously failing?

---

<div class="post-metadata">

**Author:** ![Spedix](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/spedix/32/48136_2.png) [@Spedix](https://community.fly.io/u/Spedix)\
**Post date:** [February 20, 2025, 7:13pm UTC](https://community.fly.io/t/moving-to-a-monorepo-litefs-and-prisma/23973/4 "2025-02-20T19:13:56Z")

</div>

Yes exactly! It is working but instead of saying: “heey it works, thats it” I was curious about how and why.

Thanks for the clarification!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [February 27, 2025, 7:14pm UTC](https://community.fly.io/t/moving-to-a-monorepo-litefs-and-prisma/23973/5 "2025-02-27T19:14:33Z")

</div>

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