Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Oct 29, 2023
2 parents 6a8227f + 0fc6a10 commit c9d97e6
Show file tree
Hide file tree
Showing 63 changed files with 1,364 additions and 361 deletions.
2 changes: 2 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { ContributionModule } from './features/contribution/contribution.module'
import { ThrottlerModule } from '@nestjs/throttler';
import { postgresDataSourceOptions } from './db/data-source';
import { MailModule } from './features/mail/mail.module';
import { Countries } from './entities/flaskEntities/countries.entity';

const imports = [
ThrottlerModule.forRoot({
Expand All @@ -59,6 +60,7 @@ const imports = [
TypeOrmModule.forRoot({
...config().db2,
entities: [
Countries,
Need,
SocialWorker,
NGO,
Expand Down
8 changes: 4 additions & 4 deletions src/db/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { NgoArrivalEntity, NgoEntity } from '../entities/ngo.entity';
import { TicketEntity } from '../entities/ticket.entity';
import { TicketContentEntity } from '../entities/ticketContent.entity';
import { StatusEntity } from '../entities/status.entity';
import { CityEntity } from '../entities/city.entity';
import { LocationEntity } from '../entities/location.entity';
import { TicketViewEntity } from '../entities/ticketView.entity';
import { IpfsEntity } from '../entities/ipfs.entity';
import { ContributorEntity } from '../entities/contributor.entity';
Expand All @@ -31,7 +31,7 @@ export const postgresDataSourceOptions: DataSourceOptions = {
entities: [
Session,
AllUserEntity,
CityEntity,
LocationEntity,
StatusEntity,
ContributorEntity,
TicketEntity,
Expand All @@ -54,8 +54,8 @@ export const postgresDataSourceOptions: DataSourceOptions = {
IpfsEntity,
MidjourneyEntity,
CommentEntity,
ChildrenPreRegisterEntity
],
ChildrenPreRegisterEntity,
],
};

const dataSource = new DataSource(postgresDataSourceOptions);
Expand Down
14 changes: 0 additions & 14 deletions src/db/migrations/1698251652822-new.ts

This file was deleted.

164 changes: 164 additions & 0 deletions src/db/migrations/1698395142941-new.ts

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/db/migrations/1698406143230-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698406143230 implements MigrationInterface {
name = 'New1698406143230'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "birthPlace"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "birthPlaceId" integer`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "birthPlaceName" character varying`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "birthPlaceName"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "birthPlaceId"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "birthPlace" integer`);
}

}
16 changes: 16 additions & 0 deletions src/db/migrations/1698407672749-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698407672749 implements MigrationInterface {
name = 'New1698407672749'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "bio"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "bio" hstore`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "bio"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "bio" character varying`);
}

}
20 changes: 20 additions & 0 deletions src/db/migrations/1698426095522-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698426095522 implements MigrationInterface {
name = 'New1698426095522'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "socialWorkerId" uuid`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "ngoId" uuid NOT NULL`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD CONSTRAINT "FK_61094282a2c5eca786880ba1c86" FOREIGN KEY ("socialWorkerId") REFERENCES "contributor_entity"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD CONSTRAINT "FK_11bdf6d719c11cfc798c99a3ec9" FOREIGN KEY ("ngoId") REFERENCES "ngo_entity"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP CONSTRAINT "FK_11bdf6d719c11cfc798c99a3ec9"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP CONSTRAINT "FK_61094282a2c5eca786880ba1c86"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "ngoId"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "socialWorkerId"`);
}

}
18 changes: 18 additions & 0 deletions src/db/migrations/1698427011214-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698427011214 implements MigrationInterface {
name = 'New1698427011214'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP CONSTRAINT "FK_11bdf6d719c11cfc798c99a3ec9"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ALTER COLUMN "ngoId" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD CONSTRAINT "FK_11bdf6d719c11cfc798c99a3ec9" FOREIGN KEY ("ngoId") REFERENCES "ngo_entity"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP CONSTRAINT "FK_11bdf6d719c11cfc798c99a3ec9"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ALTER COLUMN "ngoId" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD CONSTRAINT "FK_11bdf6d719c11cfc798c99a3ec9" FOREIGN KEY ("ngoId") REFERENCES "ngo_entity"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
}

}
18 changes: 18 additions & 0 deletions src/db/migrations/1698477148560-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698477148560 implements MigrationInterface {
name = 'New1698477148560'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" RENAME COLUMN "isApproved" TO "status"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "status"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "status" integer DEFAULT '0'`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "status"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "status" boolean DEFAULT false`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" RENAME COLUMN "status" TO "isApproved"`);
}

}
18 changes: 18 additions & 0 deletions src/db/migrations/1698498268673-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698498268673 implements MigrationInterface {
name = 'New1698498268673'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "education"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "educationLevel" integer`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "schoolType" integer`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "schoolType"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "educationLevel"`);
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "education" integer`);
}

}
14 changes: 14 additions & 0 deletions src/db/migrations/1698509521151-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698509521151 implements MigrationInterface {
name = 'New1698509521151'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ALTER COLUMN "sex" SET NOT NULL`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ALTER COLUMN "sex" DROP NOT NULL`);
}

}
14 changes: 14 additions & 0 deletions src/db/migrations/1698509621401-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class New1698509621401 implements MigrationInterface {
name = 'New1698509621401'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" ADD "flaskChildId" integer`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "children_pre_register_entity" DROP COLUMN "flaskChildId"`);
}

}
50 changes: 44 additions & 6 deletions src/entities/childrenPreRegister.entity.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Entity, Column } from 'typeorm';
import { Entity, Column, ManyToOne } from 'typeorm';
import { BaseEntity } from './BaseEntity';
import {
EducationEnum,
HousingEnum,
PreRegisterStatusEnum,
SchoolTypeEnum,
SexEnum,
} from '../types/interfaces/interface';
import { LocationEntity } from './location.entity';
import { ContributorEntity } from './contributor.entity';
import { NgoEntity } from './ngo.entity';

@Entity()
export class ChildrenPreRegisterEntity extends BaseEntity {
Expand All @@ -17,26 +22,44 @@ export class ChildrenPreRegisterEntity extends BaseEntity {
@Column({ type: 'hstore', hstoreType: 'object', nullable: false })
sayName: Record<string, string>;

@Column({ nullable: true })
bioTranslations: string;
@Column({ type: 'hstore', hstoreType: 'object', nullable: true })
firstName: Record<string, string>;

@Column({ type: 'hstore', hstoreType: 'object', nullable: true })
lastName: Record<string, string>;

@Column({ type: 'hstore', hstoreType: 'object', nullable: true })
bio: Record<string, string>;

@Column({ type: 'timestamptz', nullable: true })
birthDate: Date;

@Column({ nullable: true })
birthPlace: number;
birthPlaceId: number;

@Column({ nullable: true })
flaskChildId: number;

@Column({ nullable: true })
birthPlaceName: string;

@Column({ nullable: true })
city: number;

@Column({ nullable: true })
country: number;
state: number;

@Column({ nullable: true })
country: number;

@Column({ nullable: false })
sex: SexEnum;

@Column({ nullable: true })
education: EducationEnum;
educationLevel: EducationEnum;

@Column({ nullable: true })
schoolType: SchoolTypeEnum;

@Column({ nullable: true })
housingStatus: HousingEnum;
Expand All @@ -47,6 +70,9 @@ export class ChildrenPreRegisterEntity extends BaseEntity {
@Column({ nullable: true })
address: string;

@Column({ nullable: true })
familyCount: number;

@Column({ nullable: true })
phoneNumber: string;

Expand All @@ -55,4 +81,16 @@ export class ChildrenPreRegisterEntity extends BaseEntity {

@Column({ nullable: true })
voiceUrl: string;

@Column({ nullable: true, default: PreRegisterStatusEnum.NOT_REGISTERED })
status: PreRegisterStatusEnum;

@ManyToOne(() => LocationEntity, (n) => n.preRegisters, { eager: true })
location: LocationEntity;

@ManyToOne(() => ContributorEntity, (s) => s.preRegisters, { eager: true })
socialWorker: ContributorEntity;

@ManyToOne(() => NgoEntity, (n) => n.preRegisters, { eager: true })
ngo: NgoEntity;
}
40 changes: 0 additions & 40 deletions src/entities/city.entity.ts

This file was deleted.

19 changes: 8 additions & 11 deletions src/entities/contributor.entity.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import {
Entity,
Column,
OneToMany,
ManyToOne,
} from 'typeorm';
import { Entity, Column, OneToMany, ManyToOne } from 'typeorm';
import { ChildrenEntity } from './children.entity';
import { NgoEntity } from './ngo.entity';
import { BaseEntity } from './BaseEntity';
import { AllUserEntity } from './user.entity';
import { PanelContributors, } from 'src/types/interfaces/interface';

import { PanelContributors } from 'src/types/interfaces/interface';
import { ChildrenPreRegisterEntity } from './childrenPreRegister.entity';

@Entity() // panel admin, sw, auditor, ...
export class ContributorEntity extends BaseEntity {
Expand All @@ -22,6 +17,11 @@ export class ContributorEntity extends BaseEntity {
@OneToMany(() => ChildrenEntity, (c) => c.socialWorker, { eager: false })
children?: ChildrenEntity[];

@OneToMany(() => ChildrenPreRegisterEntity, (c) => c.socialWorker, {
eager: false,
})
preRegisters?: ChildrenPreRegisterEntity[];

@ManyToOne(() => NgoEntity, (n) => n.socialWorkers, { eager: false })
ngo?: NgoEntity;

Expand All @@ -34,6 +34,3 @@ export class ContributorEntity extends BaseEntity {
@Column({ nullable: false })
panelRoleName: string;
}



6 changes: 6 additions & 0 deletions src/entities/flaskEntities/child.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export class Child extends BaseEntity {
@Column({ nullable: true })
birthPlace: string;

@Column({ nullable: true })
phoneNumber: string;

@Column({ nullable: true })
city: number;

Expand Down Expand Up @@ -97,6 +100,9 @@ export class Child extends BaseEntity {
@Column({ nullable: true })
status: number;

@Column({ nullable: true })
gender: boolean; // true:male | false:female

@Column({ type: 'timestamptz', nullable: true })
updated: Date;

Expand Down
Loading

0 comments on commit c9d97e6

Please sign in to comment.