const {JSONArrayColumn} = require('../database-types');

module.exports = (sequelize, Sequelize) => {
  return sequelize.define('transaction', {
    event: Sequelize.STRING,
    object: Sequelize.STRING,
    objectId: Sequelize.STRING,
    accountId: Sequelize.STRING,
    changedFields: JSONArrayColumn('changedFields'),
  }, {
    instanceMethods: {
      toJSON: function toJSON() {
        return {
          id: `${this.id}`,
          event: this.event,
          object: this.object,
          objectId: `${this.objectId}`,
        }
      },
    },
  });
}

@@ -318,24 +318,79 @@
 s'),%0A  %7D, %7B%0A
+    indexes: %5B%0A      %7B fields: %5B'accountId'%5D %7D,%0A    %5D,%0A
     instance

add accountId index definition to Transaction table