I am trying to use migrations with knex and bookshelf, and so far thats my code, it is an example from the bookshelf documentation:
exports.up = function(knex, Promise) {
return knex.schema.createTable('books', function(table) {
table.increments('id').primary();
table.string('name');
}).createTable('summaries', function(table) {
table.increments('id').primary();
table.string('details');
table.integer('book_id').unique().references('books.id');
});
};
I tried run:
knex migrate:make my_migration_name
knex migrate:latest
knex migrate:rollback
But not a single change in my database. Any ideas how I can get it working?
Use .then()
to create a chain of promises:
exports.up = function(knex, Promise) {
return knex.schema.createTable('books', function(table) {
table.increments('id').primary();
table.string('name');
}).then(function() {
return createTable('summaries', function(table) {
table.increments('id').primary();
table.string('details');
table.integer('book_id').unique().references('books.id');
});
});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With