Skip to content

Instantly share code, notes, and snippets.

@ashleygwilliams
Last active August 29, 2015 14:26
Show Gist options
  • Save ashleygwilliams/64fa852f58c07dcddf58 to your computer and use it in GitHub Desktop.
Save ashleygwilliams/64fa852f58c07dcddf58 to your computer and use it in GitHub Desktop.
Ashleys-MacBook-Pro:api.webmaker.org ag_dubs$ knex migrate:latest
Using environment: development
[ { sql: 'select * from information_schema.tables where table_name = ?',
bindings: [ 'migrations' ],
output: [Function: output] } ]
[ { sql: 'create table "migrations" ("id" serial primary key, "name" varchar(255), "batch" integer, "migration_time" timestamptz)',
bindings: [] } ]
{ method: 'select',
options: {},
bindings: [],
sql: 'select "name" from "migrations" order by "id" asc' }
{ method: 'select',
options: {},
bindings: [],
sql: 'select max("batch") as "max_batch" from "migrations"' }
Knex:warning - migration 00_create_users_table.js did not return a promise
[ { sql: 'select * from information_schema.tables where table_name = ?',
bindings: [ 'users' ],
output: [Function: output] } ]
Unhandled rejection Error: Transaction query already complete, run with DEBUG=knex:tx for more info
'use strict';
exports.up = function(knex) {
knex.schema.hasTable('users').then(function(exists) {
if (!exists) {
return knex.schema.createTable('users', function(t) {
t.bigIncrements('id').notNullable().primary();
t.string('username').unique().notNullable();
t.string('language').notNullable().defaultTo('en');
t.string('country').notNullable().defaultTo('US');
t.boolean('moderator').notNullable().defaultTo(false);
t.boolean('staff').notNullable().defaultTo(false);
t.timestamp('deleted_at').defaultTo(null);
t.timestamp('created_at').notNullable().defaultTo(knex.raw('now()'));
t.timestamp('updated_at').notNullable().defaultTo(knex.raw('now()'));
});
} else {
return knex.table('users');
}
});
};
exports.down = function(knex) {
return knex.schema.dropTable('users');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment