Skip to content

Instantly share code, notes, and snippets.

@wesleymilan
Forked from kopipejst/migrate.js
Last active August 29, 2015 14:22
Show Gist options
  • Save wesleymilan/6c89b59735c49442031e to your computer and use it in GitHub Desktop.
Save wesleymilan/6c89b59735c49442031e to your computer and use it in GitHub Desktop.
/**
* loopback: create build-in models tables
*
* put migrate.js file in server folder
* run `node migrate.js`
* @type {[type]}
*/
var app = require('./server');
var dataSource = app.dataSources.db;
dataSource.automigrate('User', function(err) {
if (!err) {
console.log('User table created');
} else {
console.log('-- User table not created');
}
dataSource.automigrate('AccessToken', function(err) {
if (!err) {
console.log('AccessToken table created');
} else {
console.log('-- AccessToken table not created');
}
dataSource.automigrate('ACL', function(err) {
if (!err) {
console.log('ACL table created');
} else {
console.log('-- ACL table not created');
}
dataSource.automigrate('RoleMapping', function(err) {
if (!err) {
console.log('RoleMapping table created');
} else {
console.log('-- RoleMapping table not created');
}
dataSource.automigrate('Role', function(err) {
if (!err) {
console.log('Role table created');
} else {
console.log('-- Role table not created');
}
dataSource.disconnect(); // close connection
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment