Skip to content

Commit

Permalink
fix: migration to remove extrinsicHash
Browse files Browse the repository at this point in the history
  • Loading branch information
kilted-andres committed Aug 12, 2024
1 parent 2cd7cc4 commit b33aa56
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/migrations/20240807162056-removeExtrinsicHash.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,51 @@
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface) {
// First, drop the 'search' column since it depends on 'extrinsicHash'
await queryInterface.removeColumn('CTypes', 'search');

// safely drop the 'extrinsicHash' column
await queryInterface.removeColumn('CTypes', 'extrinsicHash');

// recreate the 'search' column without 'extrinsicHash'
await queryInterface.addColumn(
'CTypes',
'search',
`tsvector generated always as (to_tsvector('english',
coalesce("id"::text, '') || ' ' ||
coalesce("schema"::text, '') || ' ' ||
coalesce("title"::text, '') || ' ' ||
coalesce("properties"::text, '') || ' ' ||
coalesce("type"::text, '') || ' ' ||
coalesce("creator"::text, '') || ' ' ||
coalesce("block"::text, '') || ' ' ||
coalesce("description"::text, ''))
) stored`,
);
},

async down(queryInterface, Sequelize) {
// First, drop the 'search' column
await queryInterface.removeColumn('CTypes', 'search');
// Recreate the 'extrinsicHash' column
await queryInterface.addColumn('CTypes', 'extrinsicHash', {
type: Sequelize.STRING,
allowNull: false,
});
await queryInterface.addColumn(
'CTypes',
'search',
`tsvector generated always as (to_tsvector('english',
coalesce("id"::text, '') || ' ' ||
coalesce("schema"::text, '') || ' ' ||
coalesce("title"::text, '') || ' ' ||
coalesce("properties"::text, '') || ' ' ||
coalesce("type"::text, '') || ' ' ||
coalesce("creator"::text, '') || ' ' ||
coalesce("extrinsicHash"::text, '') || ' ' ||
coalesce("block"::text, '') || ' ' ||
coalesce("description"::text, ''))
) stored`,
);
},
};

0 comments on commit b33aa56

Please sign in to comment.