I just put my node.js project up on elastic beanstalk and it is configured properly.
I now have the application connected to my RDS postgres DB through the knex plugin.
Locally, to run a knex migration to update the local database, i would just run this in the console "knex migrate:latest" however that wont exactly work for elastic beanstalk because I can't run commands from inside the project folder(at least I don't think I can).
How do I run knex commands on my elastic beanstalk app?
bear in mind, I'm pretty green to elastic beanstalk.
Elastic Beanstalk will run the prestart
and poststart
scripts in your package.json file.
{
"name": "...",
"version": "1.0.0",
"description": "...",
"scripts": {
"prestart": "node ./node_modules/knex/lib/bin/cli.js migrate:latest",
"poststart": "..."
}
}
Or you can run the migrations in your code, before starting the server:
knex.migrate.latest([config])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With