Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #105 from bcgov/IOD-226
Browse files Browse the repository at this point in the history
added default values to software columns
  • Loading branch information
SDToews authored Jul 18, 2022
2 parents 7363131 + bf2bac1 commit a29db35
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
35 changes: 35 additions & 0 deletions src/migrations/1657819940609-SoftwareRefactor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class SoftwareRefactor1657819940609 implements MigrationInterface {
name = 'SoftwareRefactor1657819940609';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "publisher" DROP NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "publisher" SET DEFAULT ''`,
);
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "administrator" DROP NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "administrator" SET DEFAULT ''`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "administrator" DROP DEFAULT`,
);
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "administrator" SET NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "publisher" DROP DEFAULT`,
);
await queryRunner.query(
`ALTER TABLE "software_titles" ALTER COLUMN "publisher" SET NOT NULL`,
);
}
}
10 changes: 8 additions & 2 deletions src/software/software.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ export class SoftwareTitleEntity extends GenericEntity {
title: string;

@ApiProperty()
@Column()
@Column({
default: '',
nullable: true,
})
publisher: string;

@ApiProperty()
@Column()
@Column({
default: '',
nullable: true,
})
administrator: string;

@ApiProperty()
Expand Down

0 comments on commit a29db35

Please sign in to comment.