-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to link features to (sub)sets of (geodb)features_data rows
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...migrations/api/1708525796000-PrepareToStoreListOfRelevantFeaturesDataAlongsideFeatures.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,25 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class PrepareToStoreListOfRelevantFeaturesDataAlongsideFeatures1708525796000 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
/** | ||
* Only create the column; this is going to be populated - for any existing | ||
* features - through a separate script to be run outside of the | ||
* NestJS/TypeORM db migration flow, as this operation needs to deal with | ||
* data across apidb and geoprocessingdb. | ||
*/ | ||
await queryRunner.query(` | ||
ALTER TABLE features | ||
ADD COLUMN feature_data_stable_ids uuid[]; | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE features | ||
DROP COLUMN feature_data__stable_ids; | ||
`); | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
...eoprocessing/src/migrations/geoprocessing/1708524274000-AddStableIdsToFeaturesDataRows.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,44 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddStableIdsToFeaturesDataRows1708524274000 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
DROP TRIGGER tr_precompute_feature_property_list ON features_data; | ||
CREATE TRIGGER tr_precompute_feature_property_list AFTER INSERT ON features_data | ||
FOR EACH ROW EXECUTE | ||
PROCEDURE precompute_feature_property_list(); | ||
`); | ||
|
||
await queryRunner.query(` | ||
ALTER TABLE features_data | ||
ADD COLUMN stable_id uuid; | ||
CREATE INDEX features_data_stable_id__idx ON features_data(stable_id); | ||
CREATE UNIQUE INDEX features_data_unique_stable_ids_within_feature__idx ON features_data(feature_id, stable_id); | ||
`); | ||
|
||
await queryRunner.query(` | ||
UPDATE features_data | ||
SET stable_id = id; | ||
`); | ||
|
||
await queryRunner.query(` | ||
ALTER TABLE features_data | ||
ALTER COLUMN stable_id SET NOT NULL; | ||
ALTER TABLE features_data | ||
ALTER COLUMN stable_id SET DEFAULT gen_random_uuid(); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE features_data | ||
DROP COLUMN stable_id; | ||
`); | ||
} | ||
} |
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