Search code examples
mysqldatabase-migrationtypeorm

TypeORM initialize new database using migrations


How is it possible to initialize a new database with TypeORM?
When using typeorm schema:sync the schema gets generated, but the migrations table is missing.
So if I have a newer migration now, typeorm will try to apply the older migrations aswell, which of course does not work.


Solution

  • don't use schema:sync at all.

    always use migration:generate and migration:run to modify schema, including the first creation.

    when you need create a completely new db, just run all the migrations.