Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running knex migrations on elastic beanstalk

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.

like image 968
Daniel Sauer Avatar asked Aug 18 '15 20:08

Daniel Sauer


1 Answers

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]) 
like image 93
Alex Avatar answered Oct 05 '22 12:10

Alex