Skip to content

Instantly share code, notes, and snippets.

@boutell
Created January 26, 2017 01:48
Show Gist options
  • Save boutell/316cabcc1f770d4f455118f12997ac9e to your computer and use it in GitHub Desktop.
Save boutell/316cabcc1f770d4f455118f12997ac9e to your computer and use it in GitHub Desktop.
function getDb() {
knox = // ... init stuff, then ...
return knox.schema.createTableIfNotExists('users', function (table) {
table.bigIncrements();
table.string('username', 15);
table.timestamps();
})
.then(function() {
knox.schema.createTableIfNotExists('posts', function(table) {
table.bigIncrements();
table.string('post', 200);
table.bigInteger('user_id').unsigned();
table.foreign('user_id').references('users.id').onDelete('CASCADE');
});
});
}
init().then(function() {
console.log('ready');
}).catch(function(err) {
console.error(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment