Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: process every-time-returning migrations AB#23790 #1466

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -17,7 +17,7 @@

public constructor(private readonly helperService: HelperService) {}

private getDtoPerLinesDataCategory(linesDataCategory: LinesDataEnum): any {

Check warning on line 20 in services/API-service/src/api/lines-data/lines-data.service.ts

View workflow job for this annotation

GitHub Actions / ibf-api-service (12.x)

Unexpected any. Specify a different type
switch (linesDataCategory) {
case LinesDataEnum.roads:
return new RoadDto();
Expand All @@ -34,7 +34,7 @@
public async uploadJson(
linesDataCategory: LinesDataEnum,
countryCodeISO3: string,
validatedObjArray: any,

Check warning on line 37 in services/API-service/src/api/lines-data/lines-data.service.ts

View workflow job for this annotation

GitHub Actions / ibf-api-service (12.x)

Unexpected any. Specify a different type
deleteExisting = true,
) {
// Delete existing entries
Expand All @@ -53,7 +53,8 @@
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
Loading