Mintplex-Labs / anything-llm

The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, and more.
https://anythingllm.com
MIT License
22.26k stars 2.26k forks source link

[FEAT]: Make Datasource Configurable via Environment Variables #1926

Open justmenyou opened 1 month ago

justmenyou commented 1 month ago

What would you like to see?

Currently, the datasource configuration is hardcoded. This suggestion proposes making the datasource configurable via environment variables.

base on file "server/prisma/schema.prisma"

datasource db {
  provider = "sqlite"
  url      = "file:../storage/anythingllm.db"
}

it should look like

datasource db {
  provider = env("DATABASE_PROVIDER")
  url      = env("DATABASE_URL")
}

I know there are example for postgresql in the comment but i think it wolud be better to let it be env by default and make default datasource env config as "sqlite" as it intends to be

justmenyou commented 1 month ago

I just tested it but seem like Prisma dose not support the env() function in the provider argument. Is there any other way to make it as env variable?

timothycarambat commented 1 month ago

You cannot use an env() for the provider, only the location of the DB - in SQLite's case at least.

I think the only other way around this would be to have many different schemas that have different connectors, but the same schemas - which is the main reason this was never pressured because it makes things very messy in the codebase and if you use something other than SQLite, we dont use the DB to its fullest extent for performance - since SQLite is probably the most "bare bones" DB