Created
November 9, 2018 20:37
-
-
Save arathnim/8fb182df127962a5d896b3a3b4093ef5 to your computer and use it in GitHub Desktop.
This file contains 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.down = knex => | |
Promise.all([ | |
knex.schema.dropTableIfExists('boards'), | |
knex.schema.dropTableIfExists('threads'), | |
knex.schema.dropTableIfExists('posts'), | |
]) | |
exports.up = knex => | |
Promise.all([ | |
knex.schema | |
.createTable('boards', table => { | |
table.increments('boardID').primary() | |
table.string('name') | |
table.string('description') | |
}), | |
knex.schema | |
.createTable('threads', table => { | |
table.increments('threadID').primary() | |
table.string('name') | |
table.foreign('boardID').references('boardID').inTable('boards') | |
}), | |
knex.schema | |
.createTable('posts', table => { | |
table.increments('post-id').primary() | |
table.string('message') | |
table.string('author') | |
table.foreign('thread-id').references('threads') | |
}), | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment