$ knex migrate:make create_birds
exports.up = knex => {
return knex.schema.createTable('zebras', table => {
table.increments()
table.integer('stripes')
table.string('name')
table.string('location')
})
}
exports.down = knex => {
return knex.schema.dropTableIfExists('zebras')
}
$ knex migrate:latest
$ knex seed:make birds
exports.seed = function(knex) {
return knex('birds').del()
.then(function () {
return knex('birds').insert([
{ name: 'Elmo', top_speed: 45, location: 'Tokyo' },
{ name: 'Mary', top_speed: 112, location: 'Melbourne' },
{ name: 'Peggy', top_speed: 28, location: 'Costa Rica' },
{ name: 'Donovan', top_speed: 60, location: 'Patagonia' },
{ name: 'David', top_speed: 10, location: 'Maui' }
])
})
}
$ knex seed:run