Merge branch 'development' of ssh://git.eigen.co.id:2222/eigen/pos-be into development
continuous-integration/drone/tag Build was killed
Details
continuous-integration/drone/tag Build was killed
Details
commit
61d8f56385
|
@ -0,0 +1,29 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||||
|
|
||||||
|
export class UniqueNameItem1722922766205 implements MigrationInterface {
|
||||||
|
name = 'UniqueNameItem1722922766205';
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "item_bundlings" DROP CONSTRAINT "FK_a50e7abf2caba4d0394f3726b86"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "items" ADD CONSTRAINT "UQ_213736582899b3599acaade2cd1" UNIQUE ("name")`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "item_bundlings" ADD CONSTRAINT "FK_a50e7abf2caba4d0394f3726b86" FOREIGN KEY ("item_bundling_id") REFERENCES "items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "item_bundlings" DROP CONSTRAINT "FK_a50e7abf2caba4d0394f3726b86"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "items" DROP CONSTRAINT "UQ_213736582899b3599acaade2cd1"`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "item_bundlings" ADD CONSTRAINT "FK_a50e7abf2caba4d0394f3726b86" FOREIGN KEY ("item_bundling_id") REFERENCES "items"("id") ON DELETE CASCADE ON UPDATE CASCADE`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,7 +22,7 @@ export class ItemModel
|
||||||
extends BaseStatusModel<ItemEntity>
|
extends BaseStatusModel<ItemEntity>
|
||||||
implements ItemEntity
|
implements ItemEntity
|
||||||
{
|
{
|
||||||
@Column('varchar', { name: 'name' })
|
@Column('varchar', { name: 'name', unique: true })
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@Column('varchar', { name: 'image_url', nullable: true })
|
@Column('varchar', { name: 'image_url', nullable: true })
|
||||||
|
@ -116,4 +116,19 @@ export class ItemModel
|
||||||
onUpdate: 'CASCADE',
|
onUpdate: 'CASCADE',
|
||||||
})
|
})
|
||||||
gates: GateModel[];
|
gates: GateModel[];
|
||||||
|
|
||||||
|
// relasi untuk mendapatkan parent bundling
|
||||||
|
@ManyToMany(() => ItemModel, (model) => model.bundling_parents)
|
||||||
|
@JoinTable({
|
||||||
|
name: 'item_bundlings',
|
||||||
|
joinColumn: {
|
||||||
|
name: 'item_id',
|
||||||
|
referencedColumnName: 'id',
|
||||||
|
},
|
||||||
|
inverseJoinColumn: {
|
||||||
|
name: 'item_bundling_id',
|
||||||
|
referencedColumnName: 'id',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
bundling_parents: ItemModel[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,12 @@ export class BatchDeleteItemManager extends BaseBatchDeleteManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
get validateRelations(): validateRelations[] {
|
||||||
return [];
|
return [
|
||||||
|
{
|
||||||
|
relation: 'bundling_parents',
|
||||||
|
message: `Gagal! Item sudah berelasi dengen bundling`,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
get entityTarget(): any {
|
get entityTarget(): any {
|
||||||
|
|
|
@ -33,7 +33,7 @@ export class CreateItemManager extends BaseCreateManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
get uniqueColumns(): columnUniques[] {
|
get uniqueColumns(): columnUniques[] {
|
||||||
return [];
|
return [{ column: 'name' }];
|
||||||
}
|
}
|
||||||
|
|
||||||
get eventTopics(): EventTopics[] {
|
get eventTopics(): EventTopics[] {
|
||||||
|
|
|
@ -29,7 +29,12 @@ export class DeleteItemManager extends BaseDeleteManager<ItemEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
get validateRelations(): validateRelations[] {
|
get validateRelations(): validateRelations[] {
|
||||||
return [];
|
return [
|
||||||
|
{
|
||||||
|
relation: 'bundling_parents',
|
||||||
|
message: `Gagal! Item sudah berelasi dengen bundling`,
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
get entityTarget(): any {
|
get entityTarget(): any {
|
||||||
|
|
Loading…
Reference in New Issue