-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
114 additions
and
28 deletions.
There are no files selected for viewing
20 changes: 0 additions & 20 deletions
20
backend/core/src/migration/1628714025901-listings-units-summary.ts
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
backend/core/src/migration/1629225262377-update-units-summary-structure.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
|
||
export class updateUnitsSummaryStructure1629225262377 implements MigrationInterface { | ||
name = 'updateUnitsSummaryStructure1629225262377' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "units_summary" DROP CONSTRAINT "FK_a2b6519fc3d102d4611a0e2b879"`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" DROP CONSTRAINT "PK_dd5b004243c1536a412e425a9ec"`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" DROP COLUMN "property_id"`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ADD "id" uuid NOT NULL DEFAULT uuid_generate_v4()`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ADD "listing_id" uuid`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ALTER COLUMN "unit_type_id" DROP NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ALTER COLUMN "monthly_rent" DROP NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ADD CONSTRAINT "PK_8d8c4940fab2a9d1b2e7ddd9e49" PRIMARY KEY ("id")`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "units_summary" DROP CONSTRAINT "PK_8d8c4940fab2a9d1b2e7ddd9e49"`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ALTER COLUMN "monthly_rent" SET NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ALTER COLUMN "unit_type_id" SET NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" DROP COLUMN "listing_id"`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" DROP COLUMN "id"`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ADD "property_id" uuid NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ADD CONSTRAINT "PK_dd5b004243c1536a412e425a9ec" PRIMARY KEY ("monthly_rent", "unit_type_id", "property_id")`); | ||
await queryRunner.query(`ALTER TABLE "units_summary" ADD CONSTRAINT "FK_a2b6519fc3d102d4611a0e2b879" FOREIGN KEY ("property_id") REFERENCES "property"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
import { OmitType } from "@nestjs/swagger" | ||
import { Expose } from "class-transformer" | ||
import { IsString, IsUUID } from "class-validator" | ||
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum" | ||
import { UnitsSummary } from "../entities/units-summary.entity" | ||
|
||
export class UnitsSummaryDto extends OmitType(UnitsSummary, [] as const) {} | ||
export class UnitsSummaryCreateDto extends OmitType(UnitsSummaryDto, [] as const) {} | ||
export class UnitsSummaryUpdateDto extends OmitType(UnitsSummaryDto, [] as const) {} | ||
|
||
export class UnitsSummaryCreateDto extends OmitType(UnitsSummaryDto, ["id"] as const) {} | ||
export class UnitsSummaryUpdateDto extends OmitType(UnitsSummaryCreateDto, [] as const) { | ||
@Expose() | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
@IsUUID() | ||
id: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters