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

Allow to skip the default migration creating the migrations table

Open meienberger opened this issue 2 years ago • 0 comments

Context

I'm working with esbuild as my bundler to include all dependencies in one .js bundle file. This makes it possible to ship my app with only the necessary dependencies included and to skip node_modules all together.

Problem

When bundling, the code of postgres-migrations is correctly included but the default behaviour is to use the file 0_create-migrations-table.sql which is not bundled as it is not used in my project directly. Thus giving the error :

Error: ENOENT: no such file or directory, open 'migrations/0_create-migrations-table.sql' - Offending file: '0_create-migrations-table.sql'.

Because the file doesn't exist from my bundled code.

Solution

This PR adds a simple config param skipCreateMigrationTable to avoid using the default init table. This way I can create it myself in the migrations folder of my project

Example

await migrate({ client }, path.join(__dirname, 'migrations'), { skipCreateMigrationTable: true });

meienberger avatar Dec 28 '22 19:12 meienberger