Skip to content

Commit

Permalink
SPSH-1286: Added a reference to the ImportDataItem table and refactor…
Browse files Browse the repository at this point in the history
…ed the integration tests.
  • Loading branch information
phaelcg committed Nov 29, 2024
1 parent b841bee commit fd0d026
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 123 deletions.
170 changes: 98 additions & 72 deletions migrations/.snapshot-dbildungs-iam-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -1235,66 +1235,95 @@
"length": 6,
"mappedType": "datetime"
},
"importvorgang_id": {
"name": "importvorgang_id",
"import_by_person_id": {
"name": "import_by_person_id",
"type": "uuid",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "uuid"
},
"nachname": {
"name": "nachname",
"import_by_username": {
"name": "import_by_username",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"mappedType": "string"
},
"vorname": {
"name": "vorname",
"rolle_id": {
"name": "rolle_id",
"type": "uuid",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "uuid"
},
"rollename": {
"name": "rollename",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"mappedType": "string"
},
"klasse": {
"name": "klasse",
"type": "varchar(255)",
"organisation_id": {
"name": "organisation_id",
"type": "uuid",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "string"
"mappedType": "uuid"
},
"personalnummer": {
"name": "personalnummer",
"organisationsname": {
"name": "organisationsname",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"nullable": false,
"mappedType": "string"
},
"validation_errors": {
"name": "validation_errors",
"type": "text[]",
"data_item_count": {
"name": "data_item_count",
"type": "int",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "array"
"nullable": false,
"default": "0",
"mappedType": "integer"
},
"status": {
"name": "status",
"type": "import_status_enum",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nativeEnumName": "import_status_enum",
"enumItems": [
"STARTED",
"VALID",
"INVALID",
"INPROGRESS",
"CANCELLED",
"COMPLETED",
"FAILED"
],
"mappedType": "enum"
}
},
"name": "importdataitem",
"name": "importvorgang",
"schema": "public",
"indexes": [
{
"keyName": "importdataitem_pkey",
"keyName": "importvorgang_pkey",
"columnNames": [
"id"
],
Expand Down Expand Up @@ -1517,95 +1546,66 @@
"length": 6,
"mappedType": "datetime"
},
"import_by_person_id": {
"name": "import_by_person_id",
"importvorgang_id": {
"name": "importvorgang_id",
"type": "uuid",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"nullable": false,
"mappedType": "uuid"
},
"import_by_username": {
"name": "import_by_username",
"nachname": {
"name": "nachname",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"mappedType": "string"
},
"rolle_id": {
"name": "rolle_id",
"type": "uuid",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "uuid"
},
"rollename": {
"name": "rollename",
"vorname": {
"name": "vorname",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"mappedType": "string"
},
"organisation_id": {
"name": "organisation_id",
"type": "uuid",
"klasse": {
"name": "klasse",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"mappedType": "uuid"
"mappedType": "string"
},
"organisationsname": {
"name": "organisationsname",
"personalnummer": {
"name": "personalnummer",
"type": "varchar(255)",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nullable": true,
"mappedType": "string"
},
"data_item_count": {
"name": "data_item_count",
"type": "int",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "0",
"mappedType": "integer"
},
"status": {
"name": "status",
"type": "import_status_enum",
"validation_errors": {
"name": "validation_errors",
"type": "text[]",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"nativeEnumName": "import_status_enum",
"enumItems": [
"STARTED",
"VALID",
"INVALID",
"INPROGRESS",
"CANCELLED",
"COMPLETED",
"FAILED"
],
"mappedType": "enum"
"nullable": true,
"mappedType": "array"
}
},
"name": "importvorgang",
"name": "importdataitem",
"schema": "public",
"indexes": [
{
"keyName": "importvorgang_pkey",
"keyName": "importdataitem_pkey",
"columnNames": [
"id"
],
Expand All @@ -1616,7 +1616,20 @@
}
],
"checks": [],
"foreignKeys": {},
"foreignKeys": {
"importdataitem_importvorgang_id_foreign": {
"constraintName": "importdataitem_importvorgang_id_foreign",
"columnNames": [
"importvorgang_id"
],
"localTableName": "public.importdataitem",
"referencedColumnNames": [
"id"
],
"referencedTableName": "public.importvorgang",
"updateRule": "cascade"
}
},
"nativeEnums": {
"db_seed_status_enum": {
"name": "db_seed_status_enum",
Expand Down Expand Up @@ -5125,6 +5138,19 @@
"SERVICE_PROVIDER"
]
},
"import_status_enum": {
"name": "import_status_enum",
"schema": "public",
"items": [
"STARTED",
"VALID",
"INVALID",
"INPROGRESS",
"CANCELLED",
"COMPLETED",
"FAILED"
]
},
"organisations_typ_enum": {
"name": "organisations_typ_enum",
"schema": "public",
Expand Down
18 changes: 0 additions & 18 deletions migrations/Migration20241127120235-S.ts

This file was deleted.

15 changes: 0 additions & 15 deletions migrations/Migration20241128231030-S.ts

This file was deleted.

24 changes: 24 additions & 0 deletions migrations/Migration20241129155134-S.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Migration } from '@mikro-orm/migrations';

export class Migration20241129155134 extends Migration {
public async up(): Promise<void> {
this.addSql(
"create type \"import_status_enum\" as enum ('STARTED', 'VALID', 'INVALID', 'INPROGRESS', 'CANCELLED', 'COMPLETED', 'FAILED');",
);
this.addSql(
'create table "importvorgang" ("id" uuid not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, "import_by_person_id" uuid null, "import_by_username" varchar(255) not null, "rolle_id" uuid null, "rollename" varchar(255) not null, "organisation_id" uuid null, "organisationsname" varchar(255) not null, "data_item_count" int not null default 0, "status" "import_status_enum" not null, constraint "importvorgang_pkey" primary key ("id"));',
);

this.addSql(
'alter table "importdataitem" add constraint "importdataitem_importvorgang_id_foreign" foreign key ("importvorgang_id") references "importvorgang" ("id") on update cascade;',
);
}

public override async down(): Promise<void> {
this.addSql('alter table "importdataitem" drop constraint "importdataitem_importvorgang_id_foreign";');

this.addSql('drop table if exists "importvorgang" cascade;');

this.addSql('drop type "import_status_enum";');
}
}
2 changes: 1 addition & 1 deletion src/modules/import/domain/import-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class ImportWorkflow {
const invalidImportDataItems: ImportDataItem<false>[] = [];

if (permissions.personFields.username === undefined) {
//log no username found for adminn
//log no username found for adminn instead of throwing an error
return new EntityNotFoundError('Person', permissions.personFields.id);
}
//Create ImportVorgang
Expand Down
13 changes: 10 additions & 3 deletions src/modules/import/persistence/import-data-item.entity.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { TimestampedEntity } from '../../../persistence/timestamped.entity.js';
import { ArrayType, Entity, Property } from '@mikro-orm/core';
import { ArrayType, Entity, ManyToOne, Property, Ref } from '@mikro-orm/core';
import { ImportVorgangEntity } from './import-vorgang.entity.js';

@Entity({ tableName: 'importdataitem' })
export class ImportDataItemEntity extends TimestampedEntity {
@Property({ columnType: 'uuid' })
public readonly importvorgangId!: string;
@ManyToOne({
fieldName: 'importvorgang_id',
columnType: 'uuid',
ref: true,
nullable: false,
entity: () => ImportVorgangEntity,
})
public readonly importvorgangId!: Ref<ImportVorgangEntity>;

@Property()
public readonly nachname!: string;
Expand Down
Loading

0 comments on commit fd0d026

Please sign in to comment.