Running db-migrate programtically
See original GitHub issueI would like to be able to run db-migrate programmatically, such that all migrations run on start-up of my application.
I have tried to use the Programmable API as described, such as:
var DbMigrate = require('db-migrate'); var dbm = DbMigrate.getInstance(true); dbm.run();
However, I get no such luck with this. I simply get the following error:
[ERROR] TypeError: Cannot read property 'split' of undefined
Any guidance would be great, thanks.
Node version: 4.2.4 NPM version: 2.14.12 db-migrate version: 0.10.0-beta.9 db-migrate-mysql version: 1.1.3
<bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30198377-running-db-migrate-programtically?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github). </bountysource-plugin>Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Programable API - db-migrate - Read the Docs
Programable API. This API is intended for the usage with db-migrate as a module and consists out of several functions.
Read more >How to programmatically run sequelize migrations
I dug into the code for the sequelize db:migrate command, ... IMHO, the simplest/best approach is to just run the command in a...
Read more >How to: Handle Schema Migrations Programmatically - Telerik
The OpenAccessContext exposes a method named GetSchemaHandler that returns the schema handling instance. With the schema handler in hand, there are several ...
Read more >Running migrations programmatically for automated tests
Hi guys,. I'm trying to run database migrations programmatically, inside a setUpClass() method, sharing a preconfigured connection, but the migration execution ...
Read more >How to Run Sequelize Migration Programmatically
Sequelize is a famous promise-based Node.js ORM for relational databases including PostgreSQL, MySQL, etc. Today we will be discussing how we can run...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you run your app using
npm run start
, you can add a prestart script topackage.json
to do the migrations before your app starts. In package.json you would have:@HopefulLlama Here is another example project: https://github.com/db-migrate/api-examples
Also please note: The API specification is not yet finished and there are things that are going to be improved, such as using promises on this level and so on. But from the very basic this is a very little example of how it works right now and its very likely that this will also work in the future, but will get easier, hope this helps a bit.