serverless-sequelize-migrations icon indicating copy to clipboard operation
serverless-sequelize-migrations copied to clipboard

handlers example

Open gcphost opened this issue 4 years ago • 4 comments

Hi there,

I was looking at your plugin earlier today when I was trying to find a way to run serverless migrations on deploy but disregarded it because I did not see any way to do this.

I then found serverless-pg-migrations and some how came back around to your plugin and noticed you mentioned that plugin for inspiration -- and then saw you have handlers already.

I'll be giving these a go tomorrow -- but -- wanted to comment and say it would be helpful to post an example on using your handlers on the readme.

Thanks!

gcphost avatar Sep 14 '20 07:09 gcphost

+1 I am in the same boat and would really like an example of how this works on deploy. Manual migrations are not an option as my DB is only accessible from within a VPC

circulon avatar Sep 30 '20 09:09 circulon

@circulon I ended up writing my own with umzug, in typescript, here is a screen shot of what I did.

image

gcphost avatar Sep 30 '20 14:09 gcphost

Thanks @gcphost

I really dont know much typescript at all unfortunately but I can see how you worked it out After digging around in this plugins code I found there is no facility for running migrations after deploy at all hence no documentation (Not criticising BTW just noting a feature that would be really handy)

I'm working on this issue ATM

circulon avatar Oct 01 '20 09:10 circulon

Hi guys, how are you?

I remember seeing this on the Nevon's serverless-pg-migrations package, but when I first developed this plugin for another project of mine, I didn't use the handlers directly (so maybe they are not that useful, if useful at all for your needs) because I was calling the migrations up command on the deploy processes made through the BitBucket pipeline. It was something like this:

`

image: node:10.15.3

pipelines:

branches:

qa:

  - step:

      caches:

        - node

      script:

        - npm install -g serverless

        - npm install

        - serverless config credentials --provider aws --key ${AWS_KEY} --secret ${AWS_SECRET}

        - >
          sls migrations up -r --stage qa
          --dbHost ${QA_DB_HOST}
          --dbPort ${QA_DB_PORT}
          --dbPassword ${QA_DB_PASSWORD}
          --securityGroupId1 ${SECURITY_GROUP_ID_1}
          --subnetId1 ${SUBNET_ID_1}
          --subnetId2 ${SUBNET_ID_2}
          --subnetId3 ${SUBNET_ID_3}

        - >
          sls invoke test --stage qa
          --dbHost ${QA_DB_HOST}
          --dbPort ${QA_DB_PORT}
          --dbPassword ${QA_DB_PASSWORD}
          --securityGroupId1 ${SECURITY_GROUP_ID_1}
          --subnetId1 ${SUBNET_ID_1}
          --subnetId2 ${SUBNET_ID_2}
          --subnetId3 ${SUBNET_ID_3}
          --exit

        - >
          sls deploy --stage qa
          --dbHost ${QA_DB_HOST}
          --dbPort ${QA_DB_PORT}
          --dbPassword ${QA_DB_PASSWORD}
          --securityGroupId1 ${SECURITY_GROUP_ID_1}
          --subnetId1 ${SUBNET_ID_1}
          --subnetId2 ${SUBNET_ID_2}
          --subnetId3 ${SUBNET_ID_3}

` But the handlers sound very interesting, though. I will take a look at something that could help you with this.

Thank you very much!

manelferreira avatar Oct 04 '20 18:10 manelferreira