2013-05-02 00:21:49 -04:00
|
|
|
var Q = require('q');
|
2013-05-03 23:16:15 -04:00
|
|
|
module.exports = function(Knex, item, handler, type) {
|
2013-05-02 00:21:49 -04:00
|
|
|
|
|
|
|
|
describe(item, function() {
|
|
|
|
|
|
2013-05-03 23:16:15 -04:00
|
|
|
it('creates tables with `createTable` - ' + item, function(ok) {
|
2013-05-03 12:51:54 -04:00
|
|
|
|
|
|
|
|
Knex.Schema.createTable('test_table', function(table) {
|
2013-05-02 00:21:49 -04:00
|
|
|
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();
|
2013-05-03 23:16:15 -04:00
|
|
|
}).then(handler(ok), ok);
|
2013-05-03 12:51:54 -04:00
|
|
|
|
2013-05-03 23:16:15 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('will not break on default values on text in MySql' + item, function(ok) {
|
2013-05-03 12:51:54 -04:00
|
|
|
|
2013-05-03 23:16:15 -04:00
|
|
|
Knex.Schema.createTable('other_table', function(table) {
|
|
|
|
|
table.integer('main').primary();
|
|
|
|
|
table.text('paragraph').defaultTo('Lorem ipsum Qui quis qui in.');
|
|
|
|
|
}).then(handler(ok), ok);
|
|
|
|
|
|
2013-05-02 00:21:49 -04:00
|
|
|
});
|
|
|
|
|
|
2013-05-03 23:16:15 -04:00
|
|
|
it('edits tables with table');
|
|
|
|
|
|
2013-05-02 00:21:49 -04:00
|
|
|
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('renames tables with `renameTable` - ' + item, function(ok) {
|
|
|
|
|
Knex.Schema.renameTable('accounts', 'new_accounts').then(handler(ok), ok);
|
|
|
|
|
});
|
|
|
|
|
|
2013-05-03 23:16:15 -04:00
|
|
|
if (type === 'String') return;
|
|
|
|
|
|
|
|
|
|
it('checks for table existence with `hasTable` - ' + item, function(ok) {
|
|
|
|
|
Knex.Schema.hasTable('test_table').then(handler(ok), ok);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2013-05-02 00:21:49 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
};
|