Created
March 11, 2016 14:35
-
-
Save chrisfrancis27/135424977eca74119fd4 to your computer and use it in GitHub Desktop.
Knex 0.10.0 `undefined -> DEFAULT` test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.up = function(knex) { | |
return knex.schema | |
.createTable('things', t => { | |
t.increments('id').primary().unsigned(); | |
t.text('a').notNullable().defaultTo(''); | |
t.integer('b').notNullable().defaultTo(0); | |
t.boolean('c').notNullable().defaultTo(false); | |
}) | |
; | |
}; | |
exports.down = function(knex) { | |
return knex.schema.dropTableIfExists('things'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.seed = knex => { | |
let seeds = [{ | |
a: 'lorem', | |
b: 123 | |
}, { | |
a: 'ipsum', | |
b: 456 | |
}, { | |
a: 'dolor', | |
b: 789, | |
c: true | |
}]; | |
let q = knex('things').insert(seeds); | |
console.log(`QUERY: ${q.toString()}`); | |
return q; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: