Created
January 26, 2017 01:48
-
-
Save boutell/316cabcc1f770d4f455118f12997ac9e 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
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