To generate schema from your entity metadata, you can use
You can use it via CLI:
You can also use
--runflag to fire all queries, but be careful as it might break your database. Be sure to always check the generated SQL first before executing. Do not use
--runflag in production!
schema:create will automatically create the database if it does not exist.
schema:drop will by default drop all database tables. You can use
--drop-db flag to drop
the whole database instead.
Or you can create simple script where you initialize MikroORM like this:
Then run this script via
ts-node (or compile it to plain JS and use