Closed elluminatte closed 6 years ago
The Node.js version of TypeORM supports the automatic creation of migrations. But that feature to work in the browser and with ionic Node.js needs a connection to the database. That is because it needs to check the state of your entities in the database to detected changed you made. So for now, as we haven't found a way to give node the access to the ionic sqlite database, there is no support for automatic migration generation in the browser. I guess the only option, for now, would be to create a sqlite database on your computer using the same entities and a Node.js project and create migrations that way.
How would the migrations be applied in the app? Is there an automated way to apply migrations?
@kunalgrover05 you have to list every migration in your connection options under migrations: []
(just like your entities) and set migrationsRun
to true
. This will automatically run your migrations when the connection is established.
Thanks @daniel-lang for providing the solution. However, if I am right, TypeORM still doesn't generate migrations for sqlite right? So there's actually no way to generate migrations automatically for a Cordova / Ionic setup.
With typeorm@next
the generation of migrations should work for all node.js based drivers (this includes sqlite). But the browser setup doesn't support this feature.
I guess the only option, for now, would be to create a sqlite database on your computer using the same entities and a Node.js project and create migrations that way.
Hello!
Is there any ability to auto-generate migrations for app entities?
For example, i have src/entities/category.ts:
Then i've added this code to src/app/app.component.ts:
What should i do to generate migration for Category entity creation? According docs in this repo i understood that i should write migration code myself and then add this to migrations property of createConnection(). May be there is any hint here?
Regards, Nikolay