Is there a way to programatically run new migrations?
The use case for this would be in a testing scenario (if I'm not doing something completely wrong here): - When running my tests I'd like to drop all of my existing tables in my database designated for testing - Then I'd like to generate and push the migrations based on the existing schema to the database, which will create the empty tables - Finally I'd like to seed the testing tables with some fake data that I can use as the starting point for my testing
file. But when I use these functions in my tests setup file, I get the following error:
Error: Dynamic require of "fs" is not supported
Error: Dynamic require of "fs" is not supported
.
I'm using DrizzleORM v0.36.4; with NodeJS / Express application written in Typescript and using Vitest as the testing library.
Any solutions / workarounds to this? Is there any other way I could programatically run the migrations? I think this is somewhat commonly requested feature.
We have some sync code that dynamically write tables & columns into our database based on shape of the incoming object. Therefore are not able to use a static schemas.ts file with the existing ...