Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.syncdb = function() {
var application = require('wilson/application'),
appInstances = application.getApplicationInstances(),
pieshop = require('pieshop'),
backend = pieshop.settings.get_addon('backend'),
sys = require('sys');
var table_creations = [],
deferred = [];
for(var app_name in appInstances) {
var app = appInstances[app_name];
for(var model_name in app.models) {
var model = app.models[model_name];
var table_fields = [];
for(var field_name in model.prototype._meta.fields) {
var backendField = model.prototype._meta.get_field_by_name(field_name).getBackendField(backend),
column = backendField.getColumn(field_name),
}
if(appInstance) {
var appCommand = appInstance.app.commands[command];
if(appCommand) {
appCommand.apply(appInstance, process.argv.slice(3));
} else {
sys.puts('Could not find the command '+app_and_command);
if(app === appInstance.name) {
sys.puts('Available commands within '+app);
for(var command_name in appInstance.app.commands) {
sys.puts('\t'+[app, command_name].join(':'));
}
} else {
sys.puts('All apps and commands:');
var appInstances = application.getApplicationInstances();
for(var app_name in appInstances) {
sys.puts('\t'+app_name+':');
for(var command in appInstances[app_name]) {
sys.puts('\t\t'+command);
}
}
}
}
}
};