mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added mobiledoc_revisions schema, migration script and updated tests
This commit is contained in:
parent
96488af21d
commit
91f8e03244
4 changed files with 45 additions and 3 deletions
|
@ -0,0 +1,35 @@
|
||||||
|
const common = require('../../../../lib/common');
|
||||||
|
const commands = require('../../../schema').commands;
|
||||||
|
const table = 'mobiledoc_revisions';
|
||||||
|
const message1 = 'Adding table: ' + table;
|
||||||
|
const message2 = 'Dropping table: ' + table;
|
||||||
|
|
||||||
|
module.exports.up = (options) => {
|
||||||
|
const connection = options.connection;
|
||||||
|
|
||||||
|
return connection.schema.hasTable(table)
|
||||||
|
.then(function (exists) {
|
||||||
|
if (exists) {
|
||||||
|
common.logging.warn(message1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
common.logging.info(message1);
|
||||||
|
return commands.createTable(table, connection);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.down = (options) => {
|
||||||
|
const connection = options.connection;
|
||||||
|
|
||||||
|
return connection.schema.hasTable(table)
|
||||||
|
.then(function (exists) {
|
||||||
|
if (!exists) {
|
||||||
|
common.logging.warn(message2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
common.logging.info(message2);
|
||||||
|
return commands.deleteTable(table, connection);
|
||||||
|
});
|
||||||
|
};
|
|
@ -344,5 +344,12 @@ module.exports = {
|
||||||
created_by: {type: 'string', maxlength: 24, nullable: false},
|
created_by: {type: 'string', maxlength: 24, nullable: false},
|
||||||
updated_at: {type: 'dateTime', nullable: true},
|
updated_at: {type: 'dateTime', nullable: true},
|
||||||
updated_by: {type: 'string', maxlength: 24, nullable: true}
|
updated_by: {type: 'string', maxlength: 24, nullable: true}
|
||||||
|
},
|
||||||
|
mobiledoc_revisions: {
|
||||||
|
id: {type: 'string', maxlength: 24, nullable: false, primary: true},
|
||||||
|
post_id: {type: 'string', maxlength: 24, nullable: false, index: true},
|
||||||
|
mobiledoc: {type: 'text', maxlength: 1000000000, fieldtype: 'long', nullable: true},
|
||||||
|
created_at_ts: {type: 'bigInteger', nullable: false},
|
||||||
|
created_at: {type: 'dateTime', nullable: false}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,7 +72,7 @@ describe('DB API', function () {
|
||||||
var jsonResponse = res.body;
|
var jsonResponse = res.body;
|
||||||
should.exist(jsonResponse.db);
|
should.exist(jsonResponse.db);
|
||||||
jsonResponse.db.should.have.length(1);
|
jsonResponse.db.should.have.length(1);
|
||||||
Object.keys(jsonResponse.db[0].data).length.should.eql(24);
|
Object.keys(jsonResponse.db[0].data).length.should.eql(25);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -90,7 +90,7 @@ describe('DB API', function () {
|
||||||
const jsonResponse = res.body;
|
const jsonResponse = res.body;
|
||||||
should.exist(jsonResponse.db);
|
should.exist(jsonResponse.db);
|
||||||
jsonResponse.db.should.have.length(1);
|
jsonResponse.db.should.have.length(1);
|
||||||
Object.keys(jsonResponse.db[0].data).length.should.eql(26);
|
Object.keys(jsonResponse.db[0].data).length.should.eql(27);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ var should = require('should'),
|
||||||
*/
|
*/
|
||||||
describe('DB version integrity', function () {
|
describe('DB version integrity', function () {
|
||||||
// Only these variables should need updating
|
// Only these variables should need updating
|
||||||
const currentSchemaHash = '1834b95684f1916f79e51bab8d6eac8f';
|
const currentSchemaHash = '1e26cc4d159e43a0607d72d1e44050d1';
|
||||||
const currentFixturesHash = '20292edf9fd692cbd6485267a2ac8e75';
|
const currentFixturesHash = '20292edf9fd692cbd6485267a2ac8e75';
|
||||||
|
|
||||||
// If this test is failing, then it is likely a change has been made that requires a DB version bump,
|
// If this test is failing, then it is likely a change has been made that requires a DB version bump,
|
||||||
|
|
Loading…
Add table
Reference in a new issue