manelferreira / serverless-sequelize-migrations

A Serverless plugin to manage sequelize migrations
MIT License
21 stars 17 forks source link

handlers example #21

Open gcphost opened 3 years ago

gcphost commented 3 years ago

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!

circulon commented 3 years ago

+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

gcphost commented 3 years ago

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

image

circulon commented 3 years ago

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

manelferreira commented 3 years ago

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!