-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adapt to Indexer's new block ID (#749)
* feat: logic to migrate blocks from string to integers * fix: handle search column * feat: paranoic down transformation * fix: change block type to integer on ctype model * fix: handle the null/zero cases explicitly * fix: mocked cTypes to use numbers for blocks * feat: make Integers Big on typeScript code * fix: make properties explainers available elsewhere * feat: make Integers Big on migration * fix: down migration * fix: delete migration to try new approach * feat: new tiny migration * fix: handle search dependency on migration * Squashed commit of the following: commit e26c54b Author: Andrés <[email protected]> Date: Fri Dec 6 11:30:37 2024 +0100 feat: simplify sequelize usage (#747) Rely on `dotenv` to load the environment variable `DATABASE_URI` to make it available for the sequelize configuration. On this way, there is no need to export the variable value manually. commit fc68a24 Author: Andrés <[email protected]> Date: Fri Dec 6 11:25:33 2024 +0100 chore: upgrade to node v22 (#748) * fix: use raw SQL to cast into BigInt
- Loading branch information
1 parent
07afcf6
commit fa7b63f
Showing
5 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
// First, drop the 'search' column since it depends on 'block' | ||
await queryInterface.removeColumn('CTypes', 'search'); | ||
|
||
// Transformation the type of 'block' from string to bigint | ||
await queryInterface.changeColumn('CTypes', 'block', { | ||
type: 'BIGINT using (block::bigint)', | ||
allowNull: true, | ||
}); | ||
// recreate the 'search' column | ||
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 since it depends on 'block' | ||
await queryInterface.removeColumn('CTypes', 'search'); | ||
|
||
// Transformation the type of 'block' from bigint to string | ||
await queryInterface.changeColumn('CTypes', 'block', { | ||
type: Sequelize.STRING, | ||
allowNull: true, | ||
}); | ||
|
||
// recreate the 'search' column | ||
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`, | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters