Skip to content

Instantly share code, notes, and snippets.

@ebectar
Last active June 11, 2018 21:25
Show Gist options
  • Save ebectar/04c6762866d1569261e23973373f03a1 to your computer and use it in GitHub Desktop.
Save ebectar/04c6762866d1569261e23973373f03a1 to your computer and use it in GitHub Desktop.
exports.up = function(knex, Promise) {
return knex.schema.createTable('tablename', function(table) {
// TABLE COLUMN DEFINITIONS HERE
table.increments()
table.string('colname1', 255).notNullable().defaultTo('')
table.string('colname2', 255).notNullable().defaultTo('')
table.string('colname3', 255).notNullable().defaultTo('')
table.timestamps(true, true)
// OR
// table.dateTime('created_at').notNullable().defaultTo(knex.raw('now()'))
// table.dateTime('updated_at').notNullable().defaultTo(knex.raw('now()'))
})
}
exports.down = function(knex, Promise) {
return knex.schema.dropTableIfExists('tablename')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment