Migrate from DATABASE_URL environment variable to flag
Currently the database connection information is get from an environment variable DATABASE_URL. To be more a "go thing", we could change it to be a flag --databaseURL instead of the environment var. In some scenarios, the env would be used as the value of the flag, like --databaseURL=DATABASE_URL, but that would not be mandatory
Yes, I want to solve this issue
Awesome @RidamGarg !! If you need any assistance, please let me know. Go for it.! 🚀
I have created a pull request by doing some changes. Let me know I have done it correctly or not.
@tiagostutz I'll take this issue and try to resolve it
Hi @kasheravaibhav14 ! Sorry for the late response.
I have just assigned this issue to you. Let me know if you need any assistance! Thanks!
I am writing the code for this issue, and i got a question. Is it to completely remove the env variable possibility, or just assign the flag value to the env variable so both options would be possible?
Completely remove from the Go code this. The env variable will be used as the value of the flag argument. Like:
--databaseURL=$DATABASE_URL
Makes sense to you?
Please, correct me if i am wrong, schema.prisma controls the connection with the database, and the datasource object controls the connection string used to talk to the database.
From this issue on Go Prisma client repository I understand that the way to do such connection on runtime is using env variables.
So, on test files and on dockerfile, and generate.sh i would need to update to input the connection string from a flag and schema.prisma would need to read those values form a flag as well to copmpletly remove the env variable possibility?
Am I missing something here?
Yes, you are right about setting DATABASE_URL FOR the runtime connection. So, let's discuss some possibilites. I have the following suggestion:
- we leave the environment variable in the generate.sh as it is now, because the "flag issue" we are working on is just for the Go part
- In the Go part we will read this value from the flag and we will set the ENV variable on the program startup.
This way we will have this go idiomatic way of using flags instead of environment variables directly while making Prisma work properly.
What do you think?
Yes, that was my first approach but did not seen right. I will submit a PR them.
Awesome!!