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

Change Data Stores column types to float #316

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
6 changes: 3 additions & 3 deletions apps/backend/src/app/dataStores/entity/dataStore.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ export class DataStoreEntity {
description: 'Capacity in GB',
required: true,
})
@Column({ nullable: false })
@Column({ type: 'float', nullable: false })
capacity!: number;

@ApiProperty({
description: 'High water mark in GB',
required: true,
})
@Column({ nullable: false })
@Column({ type: 'float', nullable: false })
highWaterMark!: number;

@ApiProperty({
description: 'Filled in GB',
required: true,
})
@Column({ nullable: false })
@Column({ type: 'float', nullable: false })
filled!: number;

@ApiProperty({
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/app/db-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { AddAlertAdditionalBackup1736630779875 } from './migrations/173663077987
import { StorageOverflowTime1736550460789 } from './migrations/1736550460789-StorageOverflowTime';
import { DeprecatedFlag1737107214086 } from './migrations/1737107214086-DeprecatedFlag';
import { DeprecatedFlagNewAlerts1737406388351 } from './migrations/1737406388351-DeprecatedFlagNewAlerts';
import { ChangeDatastoresColumnTypesToFloat1738509170401 } from './migrations/1738509170401-changeDatastoresColumnTypesToFloat';

/**
* Used by NestJS to reach database.
Expand Down Expand Up @@ -95,6 +96,7 @@ export class DbConfigService implements TypeOrmOptionsFactory {
StorageOverflowTime1736550460789,
DeprecatedFlag1737107214086,
DeprecatedFlagNewAlerts1737406388351,
ChangeDatastoresColumnTypesToFloat1738509170401,
],
logging: true,
logger: 'debug',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class ChangeDatastoresColumnTypesToFloat1738509170401 implements MigrationInterface {
name = 'ChangeDatastoresColumnTypesToFloat1738509170401'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "DataStore" DROP COLUMN "capacity"`);
await queryRunner.query(`ALTER TABLE "DataStore" ADD "capacity" double precision NOT NULL`);
await queryRunner.query(`ALTER TABLE "DataStore" DROP COLUMN "highWaterMark"`);
await queryRunner.query(`ALTER TABLE "DataStore" ADD "highWaterMark" double precision NOT NULL`);
await queryRunner.query(`ALTER TABLE "DataStore" DROP COLUMN "filled"`);
await queryRunner.query(`ALTER TABLE "DataStore" ADD "filled" double precision NOT NULL`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "DataStore" DROP COLUMN "filled"`);
await queryRunner.query(`ALTER TABLE "DataStore" ADD "filled" integer NOT NULL`);
await queryRunner.query(`ALTER TABLE "DataStore" DROP COLUMN "highWaterMark"`);
await queryRunner.query(`ALTER TABLE "DataStore" ADD "highWaterMark" integer NOT NULL`);
await queryRunner.query(`ALTER TABLE "DataStore" DROP COLUMN "capacity"`);
await queryRunner.query(`ALTER TABLE "DataStore" ADD "capacity" integer NOT NULL`);
}

}