Error: Can't find meta/_journal.json file when trying to apply migrations in a lambda
I'm trying to apply migration in a lambda locally with running sls invoke local -f db_run_migrations
I use serverless framework with the serverless-esbuild plugin to package my lambdas
I execute the lambda using the
sls invoke local -f db_run_migrations
command
This is my folder structure and lambda handler![](https://cdn.answeroverflow.com/1139193193586503820/image.png)
8 Replies
I'm doing the same thing in my project without issue, play around with
fs.existsSync()
to make sure the path you are setting is correct, it likely isn't
This is what we set as the path to our migrations folders path.join(__dirname, 'drizzle')
We copy the migration folder into our lambda bundle as part of our build
"postbuild": "cp -r ../../packages/database/drizzle dist",
and what's executin the 'postbuild' script? are you also using the serverless-esbuild plugin? or i assume you are using sst because i'm using serverless framewrok
the migrations are definitely not getting included now, so i just have to find out how to include them
@pandareaper is the migration folder part of all your lambda's bundle? or just the one that's doing the migration?
Just the one thats doing the migration, after the build my
dist
directory looks like this. main.js
is my javascript bundle, using webpack. drizzle
is my migration files etc. which are copied into the folder postbuild
which yarn runs automatically when I run yarn build
![](https://cdn.answeroverflow.com/1140045041197404293/image.png)
I use the CDK and bundle everything in the
dist
folder as a ZIP
Locally I use serverless-offline
and just point to the dist/main.js
as my handler, so it can work with serverless as wellyou bundle everything in the
dist
folder so you don't package them individually
so your main.js
file will have all the code for all your lambdas if i understand correctly
this is how my .build
dir look like when i esbuild bundles everything![](https://cdn.answeroverflow.com/1140212004901105664/image.png)
so then serverless-framework packages them individually ⬇️
![](https://cdn.answeroverflow.com/1140212210187120700/image.png)
ah i think i got it working, i just had to set it up in serverless framework 🤦♂️
added the
inlclude
option to my function
Nice, thats effectively equivalent to my postbuild step where I copy over the migration files 👍