Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SQLite in dev and Postgres in prod #16

Closed
tedspare opened this issue Nov 7, 2023 · 8 comments
Closed

Use SQLite in dev and Postgres in prod #16

tedspare opened this issue Nov 7, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@tedspare
Copy link
Contributor

tedspare commented Nov 7, 2023

Decoupled from #9

Some context:

  • We want to allow a demo to be deployed directly from /templates/agent
  • Everything works (see this demo) except for the DB since SQLite doesn't work in serverless (see this comment)

Possible solution:

  • Have two Prisma schemas eg. prisma.schema and local.prisma.schema
    • provider="sqlite" in the local schema and provider="postgres" in prod schema
  • Run prisma generate and prisma db push on the right schema depending on env. This could be done in bash in package.json with NODE_ENV or we could just override the build command in Vercel (or any hosting platform) to prisma generate --schema=./prisma/local.prisma.schema
@maige-app maige-app bot added the enhancement New feature or request label Nov 7, 2023
@tedspare
Copy link
Contributor Author

tedspare commented Nov 7, 2023

@iamshanvy wanna take a crack at this? 👀

@iamshanvy
Copy link
Contributor

where current postgres db is hosted?

to avoid dealing with different dbs turso could be used to host sqlite for the demo, free tier will be enough here, might be simpler solution?

@DexterStorey
Copy link
Contributor

Currently hosted on vercel postgres and it's part of our plan so the cost is negligible.

ITYJ (I trust your judgment) postgres or SQLite - whatever works, turso free tier could work but I wasn't able to set it up previously with turso super quick and gave up in favour of postgres - now I see this could be more overhead. Your call honestly if you're interested in taking this on, if not - no worries, no pressure 🧘 - can take a crack at it this weekend or colab on Gather (island.rubric.sh) any time. 🫡

@iamshanvy
Copy link
Contributor

okie, I will look into this on Friday/Saturday this week if that's good, new Open AI toys created me a bunch of work till then 😂

@iamshanvy
Copy link
Contributor

making turso work is surprisingly not straightforward 😂 I will spend some more time tomorrow, otherwise postgres it is, will update here

@iamshanvy
Copy link
Contributor

uh oh @libsql/client library which is required to use libsql (sqlite fork turso uses) is having a separate packages for client and server, causing a need to have a separated instances of prisma db (as far as my testing goes), I believe switching between local sqlite and postgresql depending on env is a simpler solution, will start working on PR

@tedspare
Copy link
Contributor Author

making turso work is surprisingly not straightforward 😂 I will spend some more time tomorrow, otherwise postgres it is, will update here

honestly man, I heard it pitched as "sqlite in prod"

This was referenced Nov 15, 2023
@tedspare
Copy link
Contributor Author

tedspare commented Nov 28, 2023

Closed by #21

Awesome work @iamshanvy 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants