1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

PostgreSQL & TypeORM: Missing relation in new DB but cannot generate migration

Discussão em 'Outras Linguagens' iniciado por Stack, Janeiro 1, 2021.

  1. Stack

    Stack Membro Participativo

    I am running PostgreSQL 12.4 with TypeORM and have been developing locally with synchronize: true without issue.

    On deployment to a staging environment where synchronize: false I get an error from a missing relation:

    query failed error: relation "xyz" does not exist


    I can reproduce the error locally by tearing down the local postgres docker container and setting synchronize: false.

    However, if I then try to generate migrations locally - to essentially 'init' the db as described in the How to initialise new database with migrations, I am told there are no changes to migrate:

    No changes in database schema were found - cannot generate a migration. To create a new empty migration use "typeorm migration:create" command


    If I then set my local envrionment back to synchronize: true and restart, I see a bunch of ALTER TABLE / CREATE INDEX queries being run which perform the migrations I need.

    Why are these migrations only being run via the synchronize option, and how can I generate the required migrations for these?

    Continue reading...

Compartilhe esta Página