mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
338109c762
- added line to index.js to set node_env to development if it is not set - fixed a small bug with the persistent notifications and used them on debug page from server side - added 002 files to manage export and import for 002 - 002 import is somewhat smarter than 001, merging settings (except version), replacing user & clearing primary keys - added reset to models and migration, which does the down operation the same way that init does the up operation - import and reset clear session & redirect to login / signup - additional unit tests
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
var _ = require("underscore"),
|
|
when = require("when"),
|
|
knex = require('../../models/base').Knex,
|
|
Exporter002;
|
|
|
|
Exporter002 = function () {
|
|
this.version = "002";
|
|
};
|
|
|
|
Exporter002.prototype.exportData = function () {
|
|
var self = this,
|
|
tables = [
|
|
'posts', 'users', 'roles', 'roles_users', 'permissions',
|
|
'permissions_roles', 'settings', 'tags', 'posts_tags',
|
|
'custom_data', 'posts_custom_data'
|
|
],
|
|
selectOps = _.map(tables, function (name) {
|
|
return knex(name).select();
|
|
});
|
|
|
|
return when.all(selectOps).then(function (tableData) {
|
|
var exportData = {
|
|
meta: {
|
|
exported_on: new Date().getTime(),
|
|
version: self.version
|
|
},
|
|
data: {
|
|
// Filled below
|
|
}
|
|
};
|
|
|
|
_.each(tables, function (name, i) {
|
|
exportData.data[name] = tableData[i];
|
|
});
|
|
|
|
return when.resolve(exportData);
|
|
}, function (err) {
|
|
console.log("Error exporting data: " + err);
|
|
});
|
|
};
|
|
|
|
module.exports = {
|
|
// Make available for unit tests
|
|
Exporter002: Exporter002,
|
|
|
|
exportData: function () {
|
|
return new Exporter002().exportData();
|
|
}
|
|
}; |