For example, when the developer adds a new property to a model, they also need to define a new column in their SQL database schema. NoSQL databases like Cloudant and MongoDB don’t require schema, but still require developers to define indices to speed up frequent queries.
Projects scaffolded with a recent version of our CLI tool
lb4 come with a new
package script that automates the database migration process.
$ npm run migrate
Under the hood, this script is a thin wrapper for a new Application API
contributed by the RepositoryMixin:
migrateSchema iterates over all datasources registered with the
application and ask the underlying connector to migrate database schema. You can
learn more in our
documentation, as well as the pull requests
In the future, we want to implement a more robust migration framework that will empower the developers to fully control database commands executed during the migration. We would like to work on these improvements together with our community, so we encourage you to join the discussion in GitHub issue #487
Originally published at https://strongloop.com/strongblog/simplify-your-database-migrations