Skip to content

Instantly share code, notes, and snippets.

View blak3r's full-sized avatar

Blake Robertson blak3r

View GitHub Profile
@blak3r
blak3r / migration.js
Last active June 2, 2022 15:22
Create a gin gin_trgm_ops index, using a sequelize migration. Once created you can use this sql command to verify the index was created properly: `SELECT * FROM pg_indexes WHERE tablename = 'table_name';`
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addIndex('Parties', {
fields: [Sequelize.literal('name gin_trgm_ops')], // <-- name = field name, gin_trgm_ops comes after the field name
using: 'gin',
indexName: 'party_name_gin_trgm_idx', // specify the index name manually otherwise sequelize will create party_
unique: false,
})