Closed vanpana closed 3 years ago
Follow-up: I see that when this happens, 'version' table has no entries actually. Doesn't sound like an error in my code, since I'm not wiping any table. Worth investigating though.
hey @vanpana, thank you for submitting the issue. Could you provide more context please. Exact steps to reproduce would be helpful :pray:
I see that when this happens, 'version' table has no entries actually
Yes, if migration table is empty then node-pg-migrate will think that it needs to start from the first migration.
I guess that the migrations were run successfully prior the error and if so, then they must have been recorded in the some table (as each migration and it's recording is run in a corresponding transaction by default - so if smth fails, the whole migration should have being rolled back). Could you confirm that you ran the runner before with the same migrationsTable name? Could you check if you don't have some suspicious other table in the DB that was created. (if you used prior cli then the default one is pgmigrations
).
Also client
option in the above code is not correct if you are using the latest version - it should be dbClient
. Please see https://salsita.github.io/node-pg-migrate/#/api
Btw it's also possible to use 'fake' option CAUTIOUSLY to recreate entries in the migrationTable without running the migrations (those will be created with new timestamps).
Thank you!
closing after no answer for a week. Please reopen if you have more questions. Thank you
I encountered an issue while using the programatic API where the migrations are already performed and the API tries to migrate the DB again (thus failing, since there are already the tables created).
The code is:
What I'm trying to achieve is migrate to the latest version.
Is there something I'm doing wrong?