Skip to content

Commit

Permalink
fix: adjust PhysicalAddress postgres migration to follow code standards
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Apr 11, 2024
1 parent 38318ae commit b8540fe
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,28 @@ export class CreateContacts1690925872592 implements MigrationInterface {

await queryRunner.query(`
CREATE TABLE "PhysicalAddress" (
"id" text PRIMARY KEY NOT NULL,
"type" varchar(255) NOT NULL,
"street_name" varchar(255) NOT NULL,
"street_number" varchar(255) NOT NULL,
"postal_code" varchar(255) NOT NULL,
"city_name" varchar(255) NOT NULL,
"province_name" varchar(255) NOT NULL,
"country_code" varchar(2) NOT NULL,
"building_name" varchar(255),
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"type" character varying(255) NOT NULL,
"street_name" character varying(255) NOT NULL,
"street_number" character varying(255) NOT NULL,
"postal_code" character varying(255) NOT NULL,
"city_name" character varying(255) NOT NULL,
"province_name" character varying(255) NOT NULL,
"country_code" character varying(2) NOT NULL,
"building_name" character varying(255),
"partyId" uuid,
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"last_updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "FK_PhysicalAddressEntity_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
"last_updated_at" TIMESTAMP NOT NULL DEFAULT now()
);`
);

await queryRunner.query(
`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "PK_PhysicalAddress_id" PRIMARY KEY ("id")`,
)

await queryRunner.query(
`ALTER TABLE "PhysicalAddress" ADD CONSTRAINT "FK_PhysicalAddress_partyId" FOREIGN KEY ("partyId") REFERENCES "Party" ("id") ON DELETE CASCADE ON UPDATE NO ACTION`,
)
}

public async down(queryRunner: QueryRunner): Promise<void> {
Expand Down

0 comments on commit b8540fe

Please sign in to comment.