stop-analyzing-api icon indicating copy to clipboard operation
stop-analyzing-api copied to clipboard

Migrate from DATABASE_URL environment variable to flag

Open tiagostutz opened this issue 5 years ago • 11 comments

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

tiagostutz avatar Sep 22 '20 22:09 tiagostutz

Yes, I want to solve this issue

RidamGarg avatar Sep 23 '20 16:09 RidamGarg

Awesome @RidamGarg !! If you need any assistance, please let me know. Go for it.! 🚀

tiagostutz avatar Sep 23 '20 19:09 tiagostutz

I have created a pull request by doing some changes. Let me know I have done it correctly or not.

RidamGarg avatar Sep 23 '20 21:09 RidamGarg

@tiagostutz I'll take this issue and try to resolve it

kasheravaibhav14 avatar Oct 09 '20 06:10 kasheravaibhav14

Hi @kasheravaibhav14 ! Sorry for the late response.

I have just assigned this issue to you. Let me know if you need any assistance! Thanks!

tiagostutz avatar Oct 15 '20 20:10 tiagostutz

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?

lbenicio-ibm avatar Jun 25 '21 15:06 lbenicio-ibm

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?

tiagostutz avatar Jun 25 '21 17:06 tiagostutz

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?

lbenicio-ibm avatar Jun 28 '21 17:06 lbenicio-ibm

Yes, you are right about setting DATABASE_URL FOR the runtime connection. So, let's discuss some possibilites. I have the following suggestion:

  1. 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
  2. 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?

tiagostutz avatar Jun 30 '21 13:06 tiagostutz

Yes, that was my first approach but did not seen right. I will submit a PR them.

lbenicio-ibm avatar Jun 30 '21 14:06 lbenicio-ibm

Awesome!!

tiagostutz avatar Jun 30 '21 14:06 tiagostutz