Skip to content

Commit

Permalink
fix: process every-time-returning migrations AB#23790
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisvisser committed Sep 25, 2023
1 parent 62fc0a0 commit 9be6f3d
Show file tree
Hide file tree
Showing 8 changed files with 855 additions and 11 deletions.
826 changes: 826 additions & 0 deletions services/API-service/migration/1695634749175-fix-issues.ts

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions services/API-service/src/api/admin-area/admin-area.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
JoinColumn,
OneToMany,
Index,
MultiPolygon,
} from 'typeorm';
import { CountryEntity } from '../country/country.entity';
import { EventPlaceCodeEntity } from '../event/event-place-code.entity';
Expand Down Expand Up @@ -43,8 +44,12 @@ export class AdminAreaEntity {
public placeCodeParent: string;

@ApiProperty()
@Column('geometry', { nullable: true })
public geom: string;
@Column('geometry', {
spatialFeatureType: 'MultiPolygon',
srid: 4326,
nullable: true,
})
public geom: MultiPolygon;

@OneToMany(
(): typeof EventPlaceCodeEntity => EventPlaceCodeEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class CountryDisasterSettingsEntity {
@ApiProperty({ example: [1, 2, 3, 4] })
@Column('int', {
array: true,
default: (): string => 'array[]::int[]',
})
public adminLevels: AdminLevel[];

Expand Down
5 changes: 4 additions & 1 deletion services/API-service/src/api/country/country.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export class CountryEntity {
coordinates: [],
},
})
@Column('geometry')
@Column('geometry', {
spatialFeatureType: 'Polygon',
srid: 4326,
})
public countryBoundingBox: BoundingBox;

@ApiProperty({ example: new Date() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const getViewQuery = (type: LinesDataEnum) => {
.select([
`line."referenceId",line.geom${
type === LinesDataEnum.roads
? `line.attributes->>'highway' as "roadType"`
? `,line.attributes->>'highway' as "highway"`
: ''
}`,
])
Expand Down
16 changes: 13 additions & 3 deletions services/API-service/src/api/lines-data/lines-data.entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Entity, PrimaryGeneratedColumn, Column, Index } from 'typeorm';
import {
Entity,
PrimaryGeneratedColumn,
Column,
Index,
Geometry,
} from 'typeorm';

export enum LinesDataEnum {
roads = 'roads',
Expand All @@ -23,6 +29,10 @@ export class LinesDataEntity {
public attributes: JSON;

@Index({ spatial: true })
@Column('geometry', { nullable: true })
public geom: string;
@Column('geometry', {
spatialFeatureType: 'GeometryCollection',
srid: 4326,
nullable: true,
})
public geom: Geometry;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export class LinesDataService {
referenceId: line.fid || null,
linesDataCategory: linesDataCategory,
attributes: JSON.parse(JSON.stringify(pointAttributes)),
geom: (): string => `ST_GeomFromText('${line.wkt}')`,
geom: (): string => `st_geomfromtext(
'GEOMETRYCOLLECTION(${line.wkt})')`,
};
});
await this.linesDataRepository.save(dataArray, { chunk: 100 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class IndicatorMetadataEntity {
@Column()
public weightedAvg: boolean;

@ApiProperty({ example: 'total_houses', nullable: true })
@Column()
@ApiProperty({ example: 'total_houses' })
@Column({ nullable: true })
public weightVar: string;

@ApiProperty({ example: 'yes' })
Expand Down

0 comments on commit 9be6f3d

Please sign in to comment.