Prod database and Test database in Drizzle
I would like to know how you are dealing with having a test (or dev) database in your projects beside the prod database.
As I'm using postgre, all my environments are in the same database, just with different schemas.
How should that reflect in my drizzle files ? Should I declare each table and each column 3 times ? (for prod, dev and test)
I can't just use an env variable, because each time I change its value and try to migrate, drizzle delete the previous schema.
16 Replies
any feedback, please ? 🥺
So you use different schemas for test, development and prod?
Have you seen this? https://orm.drizzle.team/docs/goodies#multi-project-schema
Drizzle ORM - Goodies
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
That should solve your issue but I'm not sure that's a good approach. I feel weird about having test, dev and prod all in the same db. I suggest you use docker and have your prod env far away from testing and development
I agree with you, best would be to completely separate the different environments, but I only have one database at disposal.
They asked me to use 3 differents pgSchemas for test, dev and prod
I've seen this but this would lead to have everything in one pgSchema with just prefixes on each table name
What about this option for drizzle kit? https://orm.drizzle.team/kit-docs/config-reference#schemafilter
Drizzle ORM - Config Reference
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
You can have as many databases as you want if you used docker
Based on this, ti will work: https://orm.drizzle.team/kit-docs/commands#apply-migrations
Drizzle ORM - List of commands
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
I'm really not a docker expert, gotta learn it first
this looks promising
Hello @Angelelz, I'm trying to use Docker for my test database but I don't know why my migrations won't be made
I'm getting this, as if my files were empty but i can cat them and they seem intact
Do you have any documentation or idea of my mistake ?
If you’re using docker only for the database, you would only need to change the database connection string
Let me see if I can find a playground I use to use with docker
GitHub
GitHub - rphlmr/drizzle-playground
Contribute to rphlmr/drizzle-playground development by creating an account on GitHub.
He has a dockerfile with several databases set up
i'm using docker for both, i'll try to figure it ou
I wouldn’t do it that way unless you had a reason. Using it for just the database lets you only change the connection string based on test prod or dev
I was asked to push the app as a package to GitHub, so I had to dockerize it. Now, I want to set up tests in the CI/CD pipeline, and using containers that start up and shut down on their own seems like the best way to go, right?
Well if you already have the app and the db in the same container it only makes sense