Created
August 24, 2014 01:07
-
-
Save kopipejst/3e525bdb4e856c98bfb1 to your computer and use it in GitHub Desktop.
loopback create build-in models tables
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
/** | |
* 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
Ivan, thank you very much for this example. Migration should be a build-in function in slc command.
Best regards