postgres-migrations icon indicating copy to clipboard operation
postgres-migrations copied to clipboard

Allow users to override initial migration to fix bundling issues

Open khromov opened this issue 2 years ago • 0 comments

This is a PR to work around this issue related to bundling: https://github.com/ThomWright/postgres-migrations/issues/79

There are several ways to fix the this but I believe this is the least invasive way.

I added instructions for how to use this workaround i in the README as well:

Bundling postgres-migrations

If you are bundling this package with for example Vite/Rollup, you might get the error ReferenceError: __dirname is not defined when trying to run migrations.

To work around this, you need to:

  1. Download the initial migration from this link and put it in your migrations folder.
  2. Make sure the name of the file is exactly the same as the original: 0_create-migrations-table.sql

The library will then detect the presence of the file and skip including the initial migration from inside the package using __dirname. To make sure you copied the file correctly, verify that the hash for the create-migrations-table migration in the migrations table is e18db593bcde2aca2a408c4d1100f6abba2195df.

See this issue for additional details.

khromov avatar Feb 05 '23 18:02 khromov