Add migration for media gallery indices
This commit is contained in:
parent
273248d3fd
commit
5f220a7b2c
2 changed files with 34 additions and 1 deletions
16
js/modules/migrations/18/index.js
Normal file
16
js/modules/migrations/18/index.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
exports.run = (transaction) => {
|
||||||
|
const messagesStore = transaction.objectStore('messages');
|
||||||
|
|
||||||
|
[
|
||||||
|
'numAttachments',
|
||||||
|
'numVisualMediaAttachments',
|
||||||
|
'numFileAttachments',
|
||||||
|
].forEach((name) => {
|
||||||
|
console.log(`Create message attachment metadata index: '${name}'`);
|
||||||
|
messagesStore.createIndex(
|
||||||
|
name,
|
||||||
|
['conversationId', 'received_at', name],
|
||||||
|
{ unique: false }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,6 +1,7 @@
|
||||||
const { isString, last } = require('lodash');
|
const { isString, last } = require('lodash');
|
||||||
|
|
||||||
const { runMigrations } = require('./run_migrations');
|
const { runMigrations } = require('./run_migrations');
|
||||||
|
const Migration18 = require('./18');
|
||||||
|
|
||||||
|
|
||||||
// IMPORTANT: The migrations below are run on a database that may be very large
|
// IMPORTANT: The migrations below are run on a database that may be very large
|
||||||
|
@ -133,7 +134,23 @@ const migrations = [
|
||||||
const duration = Date.now() - start;
|
const duration = Date.now() - start;
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
'Complete migration to database version 17.',
|
'Complete migration to database version 17',
|
||||||
|
`Duration: ${duration}ms`
|
||||||
|
);
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
version: 18,
|
||||||
|
migrate(transaction, next) {
|
||||||
|
console.log('Migration 18');
|
||||||
|
|
||||||
|
const start = Date.now();
|
||||||
|
Migration18.run(transaction);
|
||||||
|
const duration = Date.now() - start;
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
'Complete migration to database version 18',
|
||||||
`Duration: ${duration}ms`
|
`Duration: ${duration}ms`
|
||||||
);
|
);
|
||||||
next();
|
next();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue