diff --git a/core/server/data/migrations/versions/4.0/23-add-primary-key-brute-migrations-lock.js b/core/server/data/migrations/versions/4.0/23-add-primary-key-brute-migrations-lock.js new file mode 100644 index 0000000000..72b3b9a16d --- /dev/null +++ b/core/server/data/migrations/versions/4.0/23-add-primary-key-brute-migrations-lock.js @@ -0,0 +1,9 @@ +const logging = require('../../../../../shared/logging'); +const {createIrreversibleMigration} = require('../../utils'); +const {addPrimaryKey} = require('../../../schema/commands'); + +module.exports = createIrreversibleMigration(async (knex) => { + logging.info('Adding a primary key for the brute table'); + + await addPrimaryKey('brute', 'key', knex); +}); diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index b3f0a72f35..45daae7915 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -252,7 +252,7 @@ module.exports = { updated_by: {type: 'string', maxlength: 24, nullable: true} }, brute: { - key: {type: 'string', maxlength: 191}, + key: {type: 'string', maxlength: 191, primary: true}, firstRequest: {type: 'bigInteger'}, lastRequest: {type: 'bigInteger'}, lifetime: {type: 'bigInteger'}, diff --git a/test/unit/data/schema/integrity_spec.js b/test/unit/data/schema/integrity_spec.js index 2bcce8436e..a9d3c82796 100644 --- a/test/unit/data/schema/integrity_spec.js +++ b/test/unit/data/schema/integrity_spec.js @@ -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 = '5861ed57418a0195ea01e431b8b55335'; + const currentSchemaHash = 'd44979f33e39fafd9e1e25dd48e0d5d2'; const currentFixturesHash = '370d0da0ab7c45050b2ff30bce8896ba'; const currentSettingsHash = 'e1f85186a7c7ed76064b6026f68c6321'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';