Replies: 2 comments 1 reply
-
As per the documentation the command should be For reference https://orkhan.gitbook.io/typeorm/docs/migrations# |
Beta Was this translation helpful? Give feedback.
-
Hi @oco-adam, thank you for posting this question. We updated the documentation with an example of how to generate migrations from entities. The answer @adrien2p left won't work in the current released version of Medusa, as Medusa currently uses v https://docs.medusajs.com/advanced/backend/migrations/#step-1-create-migration-file |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm new to medusa and Typeorm - I'm trying to generate migrations for a custom medusa model by using Typeorm's generate functionality.
In the medusajs docs it says
You can alternatively use Typeorm's generate command to generate a Migration file from existing database tables, which requires setting up a data source in Typeorm. Check out Typeorm's documentation to learn how to create a data source, then use the generate command.
So I looked in Typeorm's docs here, but it is not clear to me where I should initialise this datasource and how then I can use it to generate migrations...
I have tried adding a file in in my project's root dir called datasource.js with the following content:
Then I try and generate a migration for my new custom model using the command:
but I'm getting the following error:
In the Typeorm online docs it says that -d should be the path to the datasource, but in the medusa docs and Typeorm command line tool help it says that -d indicates the directory where the migration should be created, so it seems like there is something strange going on...🧐
I've tried many different combinations (including with the option -d ./datasource.js) and none of these ways work for me.
I'm wondering if anyone is currently using this TypeORM generate functionality with Medusa and if so then please can you give me an idea of where I'm going wrong?
Beta Was this translation helpful? Give feedback.
All reactions