-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: /entities/currently-pointed/:urnPrefix (#969)
* feat: /entities/currently-pointed/:urnPrefix * Add migration * fix query :) * Mock method for testing * Add tests for new endpoint * Consider deleter deployment * Remove invalid old deployments * Add regex * Delete scenes not profiles * Update prod ids * Test something * undo change * Add missing entity * Update comment * Add new validation * Use correct version of validator * bump lib * test * Edit * bump version * Bump content-validator lib * bump libs * Use PROD entity ids * Bump lib * Bump lib * Add test for client error * Apply PR feedback * Install extension * Add varchar index
- Loading branch information
1 parent
c566bb0
commit a44411e
Showing
9 changed files
with
493 additions
and
10 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
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,61 @@ | ||
import { EntityId, Pointer } from 'dcl-catalyst-commons' | ||
import SQL from 'sql-template-strings' | ||
import { AppComponents } from '../../types' | ||
|
||
export async function getActiveDeploymentsByUrnPrefix( | ||
components: Pick<AppComponents, 'database'>, | ||
urnPrefix: string | ||
): Promise<{ pointer: Pointer; entityId: EntityId }[]> { | ||
// sql-template-strings doesn't allow ' in the query string | ||
const matchingString = `${urnPrefix}%` | ||
const query = SQL`SELECT * FROM active_pointers as p WHERE p.pointer LIKE ${matchingString};` | ||
|
||
const queryResult = (await components.database.queryWithValues(query, 'filter_by_urn_prefix')).rows | ||
|
||
const entities = queryResult.map((deployment: { entity_id: EntityId; pointer: Pointer }) => { | ||
return { | ||
entityId: deployment.entity_id, | ||
pointer: deployment.pointer | ||
} | ||
}) | ||
|
||
return entities | ||
} | ||
|
||
export async function updateActiveDeployments( | ||
components: Pick<AppComponents, 'database'>, | ||
pointers: Pointer[], | ||
entityId: EntityId | ||
): Promise<void> { | ||
const value_list = pointers.map((p, i) => { | ||
if (i < pointers.length - 1) { | ||
return SQL`(${p}, ${entityId}),` | ||
} else { | ||
return SQL`(${p}, ${entityId})` | ||
} | ||
}) | ||
// sql-template-strings accepts only values on templates, to use structs you need to append queries | ||
const query = SQL`INSERT INTO active_pointers(pointer, entity_id) VALUES ` | ||
value_list.forEach((v) => query.append(v)) | ||
query.append(SQL` ON CONFLICT(pointer) DO UPDATE SET entity_id = ${entityId};`) | ||
|
||
await components.database.queryWithValues(query) | ||
} | ||
|
||
export async function removeActiveDeployments( | ||
components: Pick<AppComponents, 'database'>, | ||
pointers: Pointer[] | ||
): Promise<void> { | ||
const value_list = pointers.map((p, i) => { | ||
if (i < pointers.length - 1) { | ||
return SQL`${p},` | ||
} else { | ||
return SQL`${p}` | ||
} | ||
}) | ||
const query = SQL`DELETE FROM active_pointers WHERE pointer IN (` | ||
value_list.forEach((v) => query.append(v)) | ||
query.append(`);`) | ||
|
||
await components.database.queryWithValues(query) | ||
} |
256 changes: 256 additions & 0 deletions
256
content/src/migrations/scripts/1646919812526_create_active_pointers.ts
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,256 @@ | ||
import { MigrationBuilder } from 'node-pg-migrate' | ||
|
||
export async function up(pgm: MigrationBuilder): Promise<void> { | ||
pgm.createTable('active_pointers', { | ||
pointer: { type: 'varchar', primaryKey: true }, | ||
entity_id: { type: 'text', notNull: true } | ||
}) | ||
|
||
pgm.sql(`CREATE INDEX active_pointers_pointer_ops_idx ON active_pointers (pointer varchar_pattern_ops);`) | ||
|
||
pgm.sql(`DELETE FROM deployment_deltas | ||
WHERE | ||
deployment = ANY ( | ||
SELECT id FROM deployments as e | ||
WHERE | ||
e.entity_id IN ('Qma8DraR8JPfMfa9v9Eeh1fFkJpJ8iXYLTWPMg9xcRHW61', | ||
'QmWWtbpt632GkuUjX3yzdYB1FrNCYAU2fU2thFtEJPWi36', | ||
'QmfFpN49XtjmcsCFchqmjyXXNX4t3d8URE2i9QA9NuzULE', | ||
'QmTtjevvkarvaww3v7a9QXuSxkuc8YJyiX9VKW3Tmcg1qz', | ||
'QmSdgEPNT1CdEacagdTjqPgPGFnQXXVpgVmVeYQNC8JYDz', | ||
'QmS4m3BPZKAbdpuqCPy9ag1oeSvTXgL1CNNnjq7Gj8hAjb', | ||
'QmXe1AFCEeTdR4HispiiW9Dkx7QcSyFBVA4AyvJuVnVswV', | ||
'QmZWDaegoUhr4oMuB4Vd8FwPrAahjkqPB3RrtPJGmZCvMX', | ||
'QmfNVq56ucaCcgXg7fBLacrm9M6Td5rP7HkTt27SK2wGic', | ||
'QmbxtmCNzCtAwPt6sg9XGgkcuf4Ugoa7NYf1Bqb2FZxYnQ', | ||
'QmdxZnvwdrpN5T7k7qQDeKBoaSnckB8moMAgQJUtaXh8D3', | ||
'QmT6EVGKs4xGQWp3XXioZJCThf8ebFopdhRCpbGG7P3iz9', | ||
'QmPjVyfo4euciWPt4H6ABVVaFfmadb5fTQt92GfZBwFVH1', | ||
'QmasZ5WL4TvtRfoWB4CJ9BHo75G7uFh2bGTpphFi8WcHao', | ||
'QmYgsjNDKzoCLtmhGfWnoXHbKtpJ3hjsqSktKwSN14NGRt', | ||
'Qmex6oPwGLQTPuLERuMzx3uBsz3T6kieSV2foxVH3HRQ3N', | ||
'QmSrstKVzaYA4NFPCcRxwgnsmqbr7Z9D7qWiMmCZz8mCb8', | ||
'QmTN4VzJYnabWAafkgqScnvqeQ3VD3hj9W7jnxBN6e2gdJ', | ||
'QmecbenQT8VJHHg86pLvr6khHrEFaCwK6T2jMHFg85eLAR', | ||
'QmR9SXZHvUVTYLnRsnTyHaovRBq4cTtoudYapKtErhmaB3', | ||
'QmfBQHZUaGmcGtpy8bbq9gFK4iXdWdpikWt61VcgA25kW3', | ||
'QmZDsE3zwmhin3p4DP5niQDGHxXBXJ4YZsDehj8K751JHi', | ||
'QmbPu37FBPQVWWmKoCUZf11HrzDvuaKXYJ3dXeK8SzhvfZ', | ||
'QmXGmrqWiicDGxgJgonfzfpvegeACYxdqauc5NFykC9JRi', | ||
'QmX5HsazaYxox9NmCYHMKwRwMRiXDC7qWsrySXMid5gdTH', | ||
'Qmd2nKrPjSZB4FWsXEWSwkRJJ37iEEVr7NoGnqkdcacVNe', | ||
'QmVtZMLjqh5NarHno6dua9mbLWC6ZzFuTJLHvp1hXmYD39', | ||
'QmfVr3wwfqiKqVbA8yW4buMqD215kPRdQrAFhhoQ8RENtY', | ||
'QmUN62XUhMuZb5GeviCZ3v9H3H1ZE3cbYJASqH4Fdh1hSP', | ||
'QmRJhrvSRWYx2WD9yWcwNekCgRSaoSMfWcubDS4pSi1tJR', | ||
'Qmccax3RmwcBMyzUiAGDXLiNJ11BgJke2RZEBqTxjrNDfu', | ||
'QmQJJA5rVujKKqvYdCfxUJUUYJ1AckW2AQCEhM7ARUynME', | ||
'QmQnYCXDfwhRGzbSbBGZe74cbq9J6EqHGSicfDQQeDwSNk', | ||
'Qmf37Pxcb8eARo8g95ewmZfaWcRvTXSPoTfYsQ9cYfXVhD', | ||
'Qmcv1XgwxXJLdL446zJ47fLxejtZD4YBBRBn3xoc8y91nG', | ||
'QmRSZm14GtxRA2zTdRVVJfty636SWEGXtmnn1TvxXBKH5f', | ||
'QmfYK2ahm6G3vaddsQJx1u3hGJPPjAe2F2fQdhuCLM5xej', | ||
'Qmf1KgiErAcEEMAxCpGYjn2rm2aLcqCHrax2ex2HykWj3W', | ||
'QmfYt8cDcNHqrdLYSNPZCCeQF9sj2n9qPTxQhSY16Srow5', | ||
'QmSCR66NTA79DrjojcHf1sRHjHqH4RLWPK1jSrnxrYufqa') | ||
);`) | ||
|
||
pgm.sql(`DELETE FROM last_deployed_pointers | ||
WHERE | ||
deployment = ANY ( | ||
SELECT id FROM deployments as e | ||
WHERE | ||
e.entity_id IN ('Qma8DraR8JPfMfa9v9Eeh1fFkJpJ8iXYLTWPMg9xcRHW61', | ||
'QmWWtbpt632GkuUjX3yzdYB1FrNCYAU2fU2thFtEJPWi36', | ||
'QmfFpN49XtjmcsCFchqmjyXXNX4t3d8URE2i9QA9NuzULE', | ||
'QmTtjevvkarvaww3v7a9QXuSxkuc8YJyiX9VKW3Tmcg1qz', | ||
'QmSdgEPNT1CdEacagdTjqPgPGFnQXXVpgVmVeYQNC8JYDz', | ||
'QmS4m3BPZKAbdpuqCPy9ag1oeSvTXgL1CNNnjq7Gj8hAjb', | ||
'QmXe1AFCEeTdR4HispiiW9Dkx7QcSyFBVA4AyvJuVnVswV', | ||
'QmZWDaegoUhr4oMuB4Vd8FwPrAahjkqPB3RrtPJGmZCvMX', | ||
'QmfNVq56ucaCcgXg7fBLacrm9M6Td5rP7HkTt27SK2wGic', | ||
'QmbxtmCNzCtAwPt6sg9XGgkcuf4Ugoa7NYf1Bqb2FZxYnQ', | ||
'QmdxZnvwdrpN5T7k7qQDeKBoaSnckB8moMAgQJUtaXh8D3', | ||
'QmT6EVGKs4xGQWp3XXioZJCThf8ebFopdhRCpbGG7P3iz9', | ||
'QmPjVyfo4euciWPt4H6ABVVaFfmadb5fTQt92GfZBwFVH1', | ||
'QmasZ5WL4TvtRfoWB4CJ9BHo75G7uFh2bGTpphFi8WcHao', | ||
'QmYgsjNDKzoCLtmhGfWnoXHbKtpJ3hjsqSktKwSN14NGRt', | ||
'Qmex6oPwGLQTPuLERuMzx3uBsz3T6kieSV2foxVH3HRQ3N', | ||
'QmSrstKVzaYA4NFPCcRxwgnsmqbr7Z9D7qWiMmCZz8mCb8', | ||
'QmTN4VzJYnabWAafkgqScnvqeQ3VD3hj9W7jnxBN6e2gdJ', | ||
'QmecbenQT8VJHHg86pLvr6khHrEFaCwK6T2jMHFg85eLAR', | ||
'QmR9SXZHvUVTYLnRsnTyHaovRBq4cTtoudYapKtErhmaB3', | ||
'QmfBQHZUaGmcGtpy8bbq9gFK4iXdWdpikWt61VcgA25kW3', | ||
'QmZDsE3zwmhin3p4DP5niQDGHxXBXJ4YZsDehj8K751JHi', | ||
'QmbPu37FBPQVWWmKoCUZf11HrzDvuaKXYJ3dXeK8SzhvfZ', | ||
'QmXGmrqWiicDGxgJgonfzfpvegeACYxdqauc5NFykC9JRi', | ||
'QmX5HsazaYxox9NmCYHMKwRwMRiXDC7qWsrySXMid5gdTH', | ||
'Qmd2nKrPjSZB4FWsXEWSwkRJJ37iEEVr7NoGnqkdcacVNe', | ||
'QmVtZMLjqh5NarHno6dua9mbLWC6ZzFuTJLHvp1hXmYD39', | ||
'QmfVr3wwfqiKqVbA8yW4buMqD215kPRdQrAFhhoQ8RENtY', | ||
'QmUN62XUhMuZb5GeviCZ3v9H3H1ZE3cbYJASqH4Fdh1hSP', | ||
'QmRJhrvSRWYx2WD9yWcwNekCgRSaoSMfWcubDS4pSi1tJR', | ||
'Qmccax3RmwcBMyzUiAGDXLiNJ11BgJke2RZEBqTxjrNDfu', | ||
'QmQJJA5rVujKKqvYdCfxUJUUYJ1AckW2AQCEhM7ARUynME', | ||
'QmQnYCXDfwhRGzbSbBGZe74cbq9J6EqHGSicfDQQeDwSNk', | ||
'Qmf37Pxcb8eARo8g95ewmZfaWcRvTXSPoTfYsQ9cYfXVhD', | ||
'Qmcv1XgwxXJLdL446zJ47fLxejtZD4YBBRBn3xoc8y91nG', | ||
'QmRSZm14GtxRA2zTdRVVJfty636SWEGXtmnn1TvxXBKH5f', | ||
'QmfYK2ahm6G3vaddsQJx1u3hGJPPjAe2F2fQdhuCLM5xej', | ||
'Qmf1KgiErAcEEMAxCpGYjn2rm2aLcqCHrax2ex2HykWj3W', | ||
'QmfYt8cDcNHqrdLYSNPZCCeQF9sj2n9qPTxQhSY16Srow5', | ||
'QmSCR66NTA79DrjojcHf1sRHjHqH4RLWPK1jSrnxrYufqa') | ||
);`) | ||
|
||
pgm.sql(`DELETE FROM pointer_history | ||
WHERE | ||
deployment = ANY ( | ||
SELECT id FROM deployments as e | ||
WHERE | ||
e.entity_id IN ('Qma8DraR8JPfMfa9v9Eeh1fFkJpJ8iXYLTWPMg9xcRHW61', | ||
'QmWWtbpt632GkuUjX3yzdYB1FrNCYAU2fU2thFtEJPWi36', | ||
'QmfFpN49XtjmcsCFchqmjyXXNX4t3d8URE2i9QA9NuzULE', | ||
'QmTtjevvkarvaww3v7a9QXuSxkuc8YJyiX9VKW3Tmcg1qz', | ||
'QmSdgEPNT1CdEacagdTjqPgPGFnQXXVpgVmVeYQNC8JYDz', | ||
'QmS4m3BPZKAbdpuqCPy9ag1oeSvTXgL1CNNnjq7Gj8hAjb', | ||
'QmXe1AFCEeTdR4HispiiW9Dkx7QcSyFBVA4AyvJuVnVswV', | ||
'QmZWDaegoUhr4oMuB4Vd8FwPrAahjkqPB3RrtPJGmZCvMX', | ||
'QmfNVq56ucaCcgXg7fBLacrm9M6Td5rP7HkTt27SK2wGic', | ||
'QmbxtmCNzCtAwPt6sg9XGgkcuf4Ugoa7NYf1Bqb2FZxYnQ', | ||
'QmdxZnvwdrpN5T7k7qQDeKBoaSnckB8moMAgQJUtaXh8D3', | ||
'QmT6EVGKs4xGQWp3XXioZJCThf8ebFopdhRCpbGG7P3iz9', | ||
'QmPjVyfo4euciWPt4H6ABVVaFfmadb5fTQt92GfZBwFVH1', | ||
'QmasZ5WL4TvtRfoWB4CJ9BHo75G7uFh2bGTpphFi8WcHao', | ||
'QmYgsjNDKzoCLtmhGfWnoXHbKtpJ3hjsqSktKwSN14NGRt', | ||
'Qmex6oPwGLQTPuLERuMzx3uBsz3T6kieSV2foxVH3HRQ3N', | ||
'QmSrstKVzaYA4NFPCcRxwgnsmqbr7Z9D7qWiMmCZz8mCb8', | ||
'QmTN4VzJYnabWAafkgqScnvqeQ3VD3hj9W7jnxBN6e2gdJ', | ||
'QmecbenQT8VJHHg86pLvr6khHrEFaCwK6T2jMHFg85eLAR', | ||
'QmR9SXZHvUVTYLnRsnTyHaovRBq4cTtoudYapKtErhmaB3', | ||
'QmfBQHZUaGmcGtpy8bbq9gFK4iXdWdpikWt61VcgA25kW3', | ||
'QmZDsE3zwmhin3p4DP5niQDGHxXBXJ4YZsDehj8K751JHi', | ||
'QmbPu37FBPQVWWmKoCUZf11HrzDvuaKXYJ3dXeK8SzhvfZ', | ||
'QmXGmrqWiicDGxgJgonfzfpvegeACYxdqauc5NFykC9JRi', | ||
'QmX5HsazaYxox9NmCYHMKwRwMRiXDC7qWsrySXMid5gdTH', | ||
'Qmd2nKrPjSZB4FWsXEWSwkRJJ37iEEVr7NoGnqkdcacVNe', | ||
'QmVtZMLjqh5NarHno6dua9mbLWC6ZzFuTJLHvp1hXmYD39', | ||
'QmfVr3wwfqiKqVbA8yW4buMqD215kPRdQrAFhhoQ8RENtY', | ||
'QmUN62XUhMuZb5GeviCZ3v9H3H1ZE3cbYJASqH4Fdh1hSP', | ||
'QmRJhrvSRWYx2WD9yWcwNekCgRSaoSMfWcubDS4pSi1tJR', | ||
'Qmccax3RmwcBMyzUiAGDXLiNJ11BgJke2RZEBqTxjrNDfu', | ||
'QmQJJA5rVujKKqvYdCfxUJUUYJ1AckW2AQCEhM7ARUynME', | ||
'QmQnYCXDfwhRGzbSbBGZe74cbq9J6EqHGSicfDQQeDwSNk', | ||
'Qmf37Pxcb8eARo8g95ewmZfaWcRvTXSPoTfYsQ9cYfXVhD', | ||
'Qmcv1XgwxXJLdL446zJ47fLxejtZD4YBBRBn3xoc8y91nG', | ||
'QmRSZm14GtxRA2zTdRVVJfty636SWEGXtmnn1TvxXBKH5f', | ||
'QmfYK2ahm6G3vaddsQJx1u3hGJPPjAe2F2fQdhuCLM5xej', | ||
'Qmf1KgiErAcEEMAxCpGYjn2rm2aLcqCHrax2ex2HykWj3W', | ||
'QmfYt8cDcNHqrdLYSNPZCCeQF9sj2n9qPTxQhSY16Srow5', | ||
'QmSCR66NTA79DrjojcHf1sRHjHqH4RLWPK1jSrnxrYufqa') | ||
);`) | ||
|
||
pgm.sql(`DELETE FROM content_files | ||
WHERE | ||
deployment = ANY ( | ||
SELECT id FROM deployments as e | ||
WHERE | ||
e.entity_id IN ('Qma8DraR8JPfMfa9v9Eeh1fFkJpJ8iXYLTWPMg9xcRHW61', | ||
'QmWWtbpt632GkuUjX3yzdYB1FrNCYAU2fU2thFtEJPWi36', | ||
'QmfFpN49XtjmcsCFchqmjyXXNX4t3d8URE2i9QA9NuzULE', | ||
'QmTtjevvkarvaww3v7a9QXuSxkuc8YJyiX9VKW3Tmcg1qz', | ||
'QmSdgEPNT1CdEacagdTjqPgPGFnQXXVpgVmVeYQNC8JYDz', | ||
'QmS4m3BPZKAbdpuqCPy9ag1oeSvTXgL1CNNnjq7Gj8hAjb', | ||
'QmXe1AFCEeTdR4HispiiW9Dkx7QcSyFBVA4AyvJuVnVswV', | ||
'QmZWDaegoUhr4oMuB4Vd8FwPrAahjkqPB3RrtPJGmZCvMX', | ||
'QmfNVq56ucaCcgXg7fBLacrm9M6Td5rP7HkTt27SK2wGic', | ||
'QmbxtmCNzCtAwPt6sg9XGgkcuf4Ugoa7NYf1Bqb2FZxYnQ', | ||
'QmdxZnvwdrpN5T7k7qQDeKBoaSnckB8moMAgQJUtaXh8D3', | ||
'QmT6EVGKs4xGQWp3XXioZJCThf8ebFopdhRCpbGG7P3iz9', | ||
'QmPjVyfo4euciWPt4H6ABVVaFfmadb5fTQt92GfZBwFVH1', | ||
'QmasZ5WL4TvtRfoWB4CJ9BHo75G7uFh2bGTpphFi8WcHao', | ||
'QmYgsjNDKzoCLtmhGfWnoXHbKtpJ3hjsqSktKwSN14NGRt', | ||
'Qmex6oPwGLQTPuLERuMzx3uBsz3T6kieSV2foxVH3HRQ3N', | ||
'QmSrstKVzaYA4NFPCcRxwgnsmqbr7Z9D7qWiMmCZz8mCb8', | ||
'QmTN4VzJYnabWAafkgqScnvqeQ3VD3hj9W7jnxBN6e2gdJ', | ||
'QmecbenQT8VJHHg86pLvr6khHrEFaCwK6T2jMHFg85eLAR', | ||
'QmR9SXZHvUVTYLnRsnTyHaovRBq4cTtoudYapKtErhmaB3', | ||
'QmfBQHZUaGmcGtpy8bbq9gFK4iXdWdpikWt61VcgA25kW3', | ||
'QmZDsE3zwmhin3p4DP5niQDGHxXBXJ4YZsDehj8K751JHi', | ||
'QmbPu37FBPQVWWmKoCUZf11HrzDvuaKXYJ3dXeK8SzhvfZ', | ||
'QmXGmrqWiicDGxgJgonfzfpvegeACYxdqauc5NFykC9JRi', | ||
'QmX5HsazaYxox9NmCYHMKwRwMRiXDC7qWsrySXMid5gdTH', | ||
'Qmd2nKrPjSZB4FWsXEWSwkRJJ37iEEVr7NoGnqkdcacVNe', | ||
'QmVtZMLjqh5NarHno6dua9mbLWC6ZzFuTJLHvp1hXmYD39', | ||
'QmfVr3wwfqiKqVbA8yW4buMqD215kPRdQrAFhhoQ8RENtY', | ||
'QmUN62XUhMuZb5GeviCZ3v9H3H1ZE3cbYJASqH4Fdh1hSP', | ||
'QmRJhrvSRWYx2WD9yWcwNekCgRSaoSMfWcubDS4pSi1tJR', | ||
'Qmccax3RmwcBMyzUiAGDXLiNJ11BgJke2RZEBqTxjrNDfu', | ||
'QmQJJA5rVujKKqvYdCfxUJUUYJ1AckW2AQCEhM7ARUynME', | ||
'QmQnYCXDfwhRGzbSbBGZe74cbq9J6EqHGSicfDQQeDwSNk', | ||
'Qmf37Pxcb8eARo8g95ewmZfaWcRvTXSPoTfYsQ9cYfXVhD', | ||
'Qmcv1XgwxXJLdL446zJ47fLxejtZD4YBBRBn3xoc8y91nG', | ||
'QmRSZm14GtxRA2zTdRVVJfty636SWEGXtmnn1TvxXBKH5f', | ||
'QmfYK2ahm6G3vaddsQJx1u3hGJPPjAe2F2fQdhuCLM5xej', | ||
'Qmf1KgiErAcEEMAxCpGYjn2rm2aLcqCHrax2ex2HykWj3W', | ||
'QmfYt8cDcNHqrdLYSNPZCCeQF9sj2n9qPTxQhSY16Srow5', | ||
'QmSCR66NTA79DrjojcHf1sRHjHqH4RLWPK1jSrnxrYufqa') | ||
);`) | ||
|
||
pgm.sql(`DELETE FROM deployments | ||
WHERE entity_id IN ('Qma8DraR8JPfMfa9v9Eeh1fFkJpJ8iXYLTWPMg9xcRHW61', | ||
'QmWWtbpt632GkuUjX3yzdYB1FrNCYAU2fU2thFtEJPWi36', | ||
'QmfFpN49XtjmcsCFchqmjyXXNX4t3d8URE2i9QA9NuzULE', | ||
'QmTtjevvkarvaww3v7a9QXuSxkuc8YJyiX9VKW3Tmcg1qz', | ||
'QmSdgEPNT1CdEacagdTjqPgPGFnQXXVpgVmVeYQNC8JYDz', | ||
'QmS4m3BPZKAbdpuqCPy9ag1oeSvTXgL1CNNnjq7Gj8hAjb', | ||
'QmXe1AFCEeTdR4HispiiW9Dkx7QcSyFBVA4AyvJuVnVswV', | ||
'QmZWDaegoUhr4oMuB4Vd8FwPrAahjkqPB3RrtPJGmZCvMX', | ||
'QmfNVq56ucaCcgXg7fBLacrm9M6Td5rP7HkTt27SK2wGic', | ||
'QmbxtmCNzCtAwPt6sg9XGgkcuf4Ugoa7NYf1Bqb2FZxYnQ', | ||
'QmdxZnvwdrpN5T7k7qQDeKBoaSnckB8moMAgQJUtaXh8D3', | ||
'QmT6EVGKs4xGQWp3XXioZJCThf8ebFopdhRCpbGG7P3iz9', | ||
'QmPjVyfo4euciWPt4H6ABVVaFfmadb5fTQt92GfZBwFVH1', | ||
'QmasZ5WL4TvtRfoWB4CJ9BHo75G7uFh2bGTpphFi8WcHao', | ||
'QmYgsjNDKzoCLtmhGfWnoXHbKtpJ3hjsqSktKwSN14NGRt', | ||
'Qmex6oPwGLQTPuLERuMzx3uBsz3T6kieSV2foxVH3HRQ3N', | ||
'QmSrstKVzaYA4NFPCcRxwgnsmqbr7Z9D7qWiMmCZz8mCb8', | ||
'QmTN4VzJYnabWAafkgqScnvqeQ3VD3hj9W7jnxBN6e2gdJ', | ||
'QmecbenQT8VJHHg86pLvr6khHrEFaCwK6T2jMHFg85eLAR', | ||
'QmR9SXZHvUVTYLnRsnTyHaovRBq4cTtoudYapKtErhmaB3', | ||
'QmfBQHZUaGmcGtpy8bbq9gFK4iXdWdpikWt61VcgA25kW3', | ||
'QmZDsE3zwmhin3p4DP5niQDGHxXBXJ4YZsDehj8K751JHi', | ||
'QmbPu37FBPQVWWmKoCUZf11HrzDvuaKXYJ3dXeK8SzhvfZ', | ||
'QmXGmrqWiicDGxgJgonfzfpvegeACYxdqauc5NFykC9JRi', | ||
'QmX5HsazaYxox9NmCYHMKwRwMRiXDC7qWsrySXMid5gdTH', | ||
'Qmd2nKrPjSZB4FWsXEWSwkRJJ37iEEVr7NoGnqkdcacVNe', | ||
'QmVtZMLjqh5NarHno6dua9mbLWC6ZzFuTJLHvp1hXmYD39', | ||
'QmfVr3wwfqiKqVbA8yW4buMqD215kPRdQrAFhhoQ8RENtY', | ||
'QmUN62XUhMuZb5GeviCZ3v9H3H1ZE3cbYJASqH4Fdh1hSP', | ||
'QmRJhrvSRWYx2WD9yWcwNekCgRSaoSMfWcubDS4pSi1tJR', | ||
'Qmccax3RmwcBMyzUiAGDXLiNJ11BgJke2RZEBqTxjrNDfu', | ||
'QmQJJA5rVujKKqvYdCfxUJUUYJ1AckW2AQCEhM7ARUynME', | ||
'QmQnYCXDfwhRGzbSbBGZe74cbq9J6EqHGSicfDQQeDwSNk', | ||
'Qmf37Pxcb8eARo8g95ewmZfaWcRvTXSPoTfYsQ9cYfXVhD', | ||
'Qmcv1XgwxXJLdL446zJ47fLxejtZD4YBBRBn3xoc8y91nG', | ||
'QmRSZm14GtxRA2zTdRVVJfty636SWEGXtmnn1TvxXBKH5f', | ||
'QmfYK2ahm6G3vaddsQJx1u3hGJPPjAe2F2fQdhuCLM5xej', | ||
'Qmf1KgiErAcEEMAxCpGYjn2rm2aLcqCHrax2ex2HykWj3W', | ||
'QmfYt8cDcNHqrdLYSNPZCCeQF9sj2n9qPTxQhSY16Srow5', | ||
'QmSCR66NTA79DrjojcHf1sRHjHqH4RLWPK1jSrnxrYufqa');`) | ||
|
||
pgm.sql('ALTER TABLE deployments DROP CONSTRAINT IF EXISTS deployments_uniq_entity_id_entity_type;') | ||
pgm.sql(`ALTER TABLE deployments ADD UNIQUE (entity_id);`) | ||
|
||
pgm.sql(` | ||
INSERT INTO active_pointers (pointer, entity_id) | ||
SELECT UNNEST(entity_pointers) as pointer, entity_id | ||
FROM deployments | ||
WHERE deleter_deployment IS NULL; | ||
`) | ||
} | ||
|
||
export async function down(pgm: MigrationBuilder): Promise<void> { | ||
pgm.dropTable('active_pointers') | ||
pgm.sql(`ALTER TABLE deployments DROP CONSTRAINT IF EXISTS deployments_uniq_entity_id;`) | ||
pgm.sql(`ALTER TABLE deployments ADD UNIQUE (entity_id, entity_type);`) | ||
} |
Oops, something went wrong.