mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added the user_id field to the api_keys table
no issue - Migration related to the Personal Tokens feature.
This commit is contained in:
parent
736c96439b
commit
214ed405cc
5 changed files with 17 additions and 1 deletions
|
@ -0,0 +1,7 @@
|
|||
const {createAddColumnMigration} = require('../../utils');
|
||||
|
||||
module.exports = createAddColumnMigration('api_keys', 'user_id', {
|
||||
type: 'string',
|
||||
maxlength: 24,
|
||||
nullable: true
|
||||
});
|
|
@ -355,6 +355,7 @@ module.exports = {
|
|||
role_id: {type: 'string', maxlength: 24, nullable: true},
|
||||
// integration_id is nullable to allow "internal" API keys that don't show in the UI
|
||||
integration_id: {type: 'string', maxlength: 24, nullable: true},
|
||||
user_id: {type: 'string', maxlength: 24, nullable: true},
|
||||
last_seen_at: {type: 'dateTime', nullable: true},
|
||||
last_seen_version: {type: 'string', maxlength: 50, nullable: true},
|
||||
created_at: {type: 'dateTime', nullable: false},
|
||||
|
|
|
@ -92,6 +92,10 @@ const ApiKey = ghostBookshelf.Model.extend({
|
|||
return this.belongsTo('Integration');
|
||||
},
|
||||
|
||||
user() {
|
||||
return this.belongsTo('User');
|
||||
},
|
||||
|
||||
format(attrs) {
|
||||
return omit(attrs, 'role');
|
||||
},
|
||||
|
|
|
@ -249,6 +249,10 @@ User = ghostBookshelf.Model.extend({
|
|||
return this.belongsToMany('Permission');
|
||||
},
|
||||
|
||||
apiKeys() {
|
||||
return this.hasMany('ApiKey', 'user_id');
|
||||
},
|
||||
|
||||
hasRole: function hasRole(roleName) {
|
||||
const roles = this.related('roles');
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ const defaultSettings = require('../../../../core/server/data/schema/default-set
|
|||
*/
|
||||
describe('DB version integrity', function () {
|
||||
// Only these variables should need updating
|
||||
const currentSchemaHash = '102b04bbd38cd2451fbf0957ffc35b30';
|
||||
const currentSchemaHash = 'cd8820283c865acf610f97252addfa99';
|
||||
const currentFixturesHash = 'd46d696c94d03e41a5903500547fea77';
|
||||
const currentSettingsHash = 'b7c0c2c6a4c61561dfefe642470d30f8';
|
||||
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
|
||||
|
|
Loading…
Reference in a new issue