Skip to content

Commit 58e84b0

Browse files
committed
feat(cardano-services): update migration with handle parent migration for parent handles
1 parent 1e9b547 commit 58e84b0

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { HandleEntity } from '@cardano-sdk/projection-typeorm';
2+
import { MigrationInterface, QueryRunner } from 'typeorm';
3+
4+
export class HandleParentMigration1700556589063 implements MigrationInterface {
5+
static entity = HandleEntity;
6+
7+
public async up(queryRunner: QueryRunner): Promise<void> {
8+
await queryRunner.query('ALTER TABLE "handle" ADD COLUMN "parent_handle_handle" character varying');
9+
await queryRunner.query(
10+
'ALTER TABLE "handle" ADD CONSTRAINT "FK_handle_parent_handle_handle" FOREIGN KEY ("parent_handle_handle") REFERENCES "handle"("handle") ON DELETE CASCADE ON UPDATE NO ACTION'
11+
);
12+
}
13+
14+
public async down(queryRunner: QueryRunner): Promise<void> {
15+
await queryRunner.query('ALTER TABLE "handle" DROP CONSTRAINT "FK_handle_parent_handle_handle"');
16+
await queryRunner.query('ALTER TABLE "handle" DROP COLUMN "parent_handle_handle"');
17+
}
18+
}

packages/cardano-services/src/Projection/migrations/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { FkPoolRegistrationMigration1682519108369 } from './1682519108369-fk-poo
88
import { FkPoolRetirementMigration1682519108370 } from './1682519108370-fk-pool-retirement';
99
import { HandleDefaultMigrations1693830294136 } from './1693830294136-handle-default-columns';
1010
import { HandleMetadataTableMigrations1693490983715 } from './1693490983715-handle-metadata-table';
11+
import { HandleParentMigration1700556589063 } from './1700556589063-handle-parent';
1112
import { HandleTableMigration1686138943349 } from './1686138943349-handle-table';
1213
import { NftMetadataTableMigration1690269355640 } from './1690269355640-nft-metadata-table';
1314
import { OutputTableMigration1682519108367 } from './1682519108367-output-table';
@@ -49,5 +50,6 @@ export const migrations: ProjectionMigration[] = [
4950
HandleDefaultMigrations1693830294136,
5051
PoolDelistedTableMigration1695899010515,
5152
CurrentStakePollMetricsAttributesMigrations1698174358997,
52-
PoolRewardsTableMigrations1698175956871
53+
PoolRewardsTableMigrations1698175956871,
54+
HandleParentMigration1700556589063
5355
];

0 commit comments

Comments
 (0)