mirror of
https://github.com/knex/knex.git
synced 2025-11-17 18:44:21 +00:00
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
var Q = require('q');
|
|
module.exports = function(Knex, item, handler) {
|
|
|
|
describe(item, function() {
|
|
|
|
it('creates tables with `table` - ' + item, function(ok) {
|
|
Knex.Schema.createTable('accounts', function(table) {
|
|
table.increments('id');
|
|
table.string('first_name');
|
|
table.string('last_name');
|
|
table.string('email').nullable();
|
|
table.integer('logins').defaultTo(1).index();
|
|
table.text('about');
|
|
table.timestamps();
|
|
})
|
|
.then(handler(ok), ok);
|
|
});
|
|
|
|
it('drops tables with `dropTable` - ' + item, function(ok) {
|
|
Knex.Schema.dropTable('accounts').then(handler(ok), ok);
|
|
});
|
|
|
|
it('conditionally drops tables with `dropTableIfExists` - ' + item, function(ok) {
|
|
Knex.Schema.dropTableIfExists('other_accounts').then(handler(ok), ok);
|
|
});
|
|
|
|
it('checks for table existence with `hasTable` - ' + item, function(ok) {
|
|
Knex.Schema.hasTable('users').then(handler(ok), ok);
|
|
});
|
|
|
|
it('renames tables with `renameTable` - ' + item, function(ok) {
|
|
Knex.Schema.renameTable('accounts', 'new_accounts').then(handler(ok), ok);
|
|
});
|
|
|
|
});
|
|
|
|
}; |