Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handlers example #21

Open
gcphost opened this issue Sep 14, 2020 · 4 comments
Open

handlers example #21

gcphost opened this issue Sep 14, 2020 · 4 comments

Comments

@gcphost
Copy link

gcphost commented Sep 14, 2020

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
Copy link

+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
Copy link
Author

gcphost commented Sep 30, 2020

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

image

@circulon
Copy link

circulon commented Oct 1, 2020

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
Copy link
Owner

manelferreira commented Oct 4, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants