Skip to content

Commit

Permalink
chore: add migration to scope unique index for inventory level
Browse files Browse the repository at this point in the history
  • Loading branch information
riqwan committed Oct 19, 2023
1 parent bee238a commit c2e9fab
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from "typeorm"

export class ScopeLevelUnique1697708391459 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP INDEX "UQ_inventory_level_inventory_item_id_location_id"`
)

await queryRunner.query(`
CREATE UNIQUE INDEX "UQ_inventory_level_inventory_item_id_location_id" ON "inventory_level" ("inventory_item_id", "location_id") WHERE deleted_at IS NULL;
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE UNIQUE INDEX "UQ_inventory_level_inventory_item_id_location_id" ON "inventory_level" ("inventory_item_id", "location_id");
`)
}
}

0 comments on commit c2e9fab

Please sign in to comment.