Closed rbcorrea closed 3 years ago
Hi, sorry for the late response.
Yes, you have to run sls migrate create -n migrationExample
, otherwise serverless thinks you are running a subcommand called migrationExample
. To understand how any command works you must run
sls migrate <command> --help
It will give you anything you need to know. But you are right, I will update the documentation.
I tested the issue you mention with a configuration as simple as
service: sls-migrate-plugin-example
provider:
name: aws
runtime: nodejs10.x
functions:
hello:
handler: handler.hello
plugins:
- serverless-migrate-plugin
and it worked
So I dont think you need to have a environment
nor a migrate
under the custom
section of your serverless.yml, and I tested it with just this dependency configuration:
"dependencies": {
"serverless-migrate-plugin": "^2.0.2"
}
Please let me know whether this problem still persists for you, otherwise I will proceed with just the documentation update.
@rbcorrea is completely correct. I just tried adding this plugin to my project that is really basic and it had a bunch of errors until I created ./migrations
and added ~migrate: environment: - local
~ the following to my serverless.yml
:
custom:
migrate:
SERVERLESS_ROOT_PATH: ./
The documentation probably needs some updating and I'm not sure if the plugin is as easy to integrate with an already started project as it might be with an empty project (though my project just includes localstack
and mocha
).
Hi @davidrhoderick, sorry to hear that. Probably you should try a config like
custom:
migrate:
environment:
SERVERLESS_ROOT_PATH: ./
Also migrate: environment: - local
is not valid, because environment is not a list.
Regarding to the documentation, I want to leave the main README as light as possible so I could go in depth about details in the README.md of the example project. This is why in the QuickStart session it said:
Check out the project located in the folder example of this repository. It contains a README with all the explanation you need to start creating your migration.
There you have info and examples for every command. If you have any recommendation about something that is missing in that documentation just let me know.
Nonetheless, I would like to help by creating a PR where I will try to make the documentation clearer and even remove the necessity of creating the migrations directory (./migrations
). Regarding the comment @rbcorrea had about the need of having a migrate
config in your serverless.yml, please check out my previous comment: Basically, you just need to add serverless-migrate-plugin
to the plugins list in the serverless.yml.
As an example of a complex configuration you can check out the config in the serverless.yml of the example project..
Please, let me know if you still have a blocker I can help you with
When trying to create a new migration, just by running
sls migrate create migrationExample
, you get the error:`Serverless Error ---------------------------------------
"add-domain" is not a valid sub command. Run "serverless migrate create" to see a more helpful error message for this command`.
If you add
-n
to the command, it runs fine.Ah, you also don't specify that you already need a
./migrations
dir to create a migration.And finally:
You'll get the error
`Type Error ---------------------------------------------
TypeError: Cannot read property 'environment' of undefined at new MigratePlugin (/home/rodrigo-correa/Documentos/mobly-services/mobly-services-stock/node_modules/serverless-migrate-plugin/index.js:105:22)`
if you don't have
environment
ormigrate
under custom section of your serverless file.More info about settings:
Your Environment Information --------------------------- Operating System: linux Node Version: 12.18.2 Framework Version: 1.71.3 Plugin Version: 3.6.12 SDK Version: 2.3.1 Components Version: 2.30.11