Skip to content

Commit

Permalink
Merge pull request #596 from code4romania/feature/590
Browse files Browse the repository at this point in the history
feat: [590] Adding new Organization Genaral Fields
  • Loading branch information
dragos1195 authored Jul 29, 2024
2 parents bc64971 + 5d4ca7a commit 509fc60
Show file tree
Hide file tree
Showing 32 changed files with 1,659 additions and 46 deletions.
34 changes: 34 additions & 0 deletions backend/src/migrations/1721829705666-AddIssuer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { ISSUERS } from './seed/issuers.seed';
import { Issuer } from 'src/shared/entities';
export class AddIssuer1721829705666 implements MigrationInterface {
name = 'AddIssuer1721829705666';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "_issuer" ("id" SERIAL NOT NULL, "deleted_on" TIMESTAMP WITH TIME ZONE, "created_on" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_on" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "name" text NOT NULL, CONSTRAINT "PK_cfe878b7aa3dc098f2ac736adc6" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_20b3d0cad6a13638d5d485eada" ON "_issuer" ("created_on") `,
);
await queryRunner.manager
.createQueryBuilder()
.insert()
.into(Issuer)
.values(ISSUERS)
.execute();
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.manager
.createQueryBuilder()
.delete()
.from(Issuer)
.execute();

await queryRunner.query(
`DROP INDEX "public"."IDX_20b3d0cad6a13638d5d485eada"`,
);
await queryRunner.query(`DROP TABLE "_issuer"`);
}
}
53 changes: 53 additions & 0 deletions backend/src/migrations/1721899705666-NewGeneralFields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

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

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "organization_general" ALTER COLUMN "raf_number" DROP NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" ADD "association_registry_number" text`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" ADD "association_registry_part" text`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" ADD "association_registry_section" text`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" ADD "association_registry_issuer_id" integer`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" ADD CONSTRAINT "FK_302f085592ed8a6c5d06f1182ef" FOREIGN KEY ("association_registry_issuer_id") REFERENCES "_issuer"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" ADD "national_registry_number" text`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "organization_general" ALTER COLUMN "raf_number" SET NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" DROP COLUMN "national_registry_number"`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" DROP CONSTRAINT "FK_302f085592ed8a6c5d06f1182ef"`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" DROP COLUMN "association_registry_issuer_id"`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" DROP COLUMN "association_registry_section"`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" DROP COLUMN "association_registry_part"`,
);
await queryRunner.query(
`ALTER TABLE "organization_general" DROP COLUMN "association_registry_number"`,
);
}
}
Loading

0 comments on commit 509fc60

Please sign in to comment.