Skip to content

Instantly share code, notes, and snippets.

@arathnim
Created November 9, 2018 20:37
Show Gist options
  • Save arathnim/8fb182df127962a5d896b3a3b4093ef5 to your computer and use it in GitHub Desktop.
Save arathnim/8fb182df127962a5d896b3a3b4093ef5 to your computer and use it in GitHub Desktop.
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