Created
June 30, 2018 21:17
-
-
Save fdjones/2a7d5d5b528a88e54d44dcaaf83878f8 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.createTableIfNotExists('authors', function (table) { | |
table.increments('uid').primary(); | |
table.string('name'); | |
table.string('password'); | |
table.string('email'); | |
}) | |
.then(res => { | |
return knex.schema.createTableIfNotExists('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.createTableIfNotExists('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.dropTableIfExists('authors'); | |
knex.schema.dropTableIfExists('thunks'); | |
knex.schema.dropTableIfExists('comments'); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment