Created
June 23, 2018 12:29
-
-
Save fdjones/25cfea816970b81e7c9590f003726ef5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
exports.up = function (knex, Promise) { | |
return knex.schema.createTable('authors', function (table) { | |
table.increments('uid').primary(); | |
table.string('name'); | |
table.string('password'); | |
table.string('email'); | |
}) | |
.then(res => { | |
return knex.schema.createTable('thunks', function (table) { | |
table.increments('id').primary(); | |
table.string('title'); | |
table.string('body'); | |
table.integer('author_id') | |
.references('uid') | |
.inTable('authors'); | |
table.dateTime('postDate'); | |
}) | |
}) | |
.then(res => { | |
return knex.schema.createTable('comments', function(table) { | |
table.increments('id').primary(); | |
table.string('body'); | |
table.integer('author_id') | |
.references('uid') | |
.inTable('authors'); | |
table.integer('post_id') | |
.references('id') | |
.inTable('thunks'); | |
table.dateTime('postDate'); | |
}) | |
}) | |
}; | |
exports.down = function (knex, Promise) { | |
knex.schema.dropTable('authors'); | |
knex.schema.dropTable('thunks'); | |
knex.schema.dropTable('comments'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment