Merge pull request #346 from Tria-plc/freight/feature/last_mile_invoice

Freight/feature/last mile invoice
This commit is contained in:
yaschalew10
2026-06-29 16:56:09 +03:00
committed by GitHub
3 changed files with 44 additions and 7 deletions

View File

@@ -34,4 +34,4 @@ RUN addgroup --system --gid 1001 nodejs \
COPY --from=deployer --chown=nestjs:nodejs /deploy .
USER nestjs
EXPOSE 3001
CMD ["node", "dist/main.js"]
CMD ["sh", "-c", "pnpm run migrate && node dist/main.js"]

View File

@@ -29,7 +29,8 @@
"iam:migration:run": "pnpm run iam:typeorm:cli migration:run",
"iam:migration:revert": "pnpm run iam:typeorm:cli migration:revert",
"iam:migration:show": "pnpm run iam:typeorm:cli migration:show",
"iam:seed:run": "cross-env APP_MODULE_PATH=./dist/app.module dotenv -- node ./node_modules/@tria-plc/iamapi-common/dist/db/seed.cli.js"
"iam:seed:run": "cross-env APP_MODULE_PATH=./dist/app.module dotenv -- node ./node_modules/@tria-plc/iamapi-common/dist/db/seed.cli.js",
"migrate": "ts-node -r tsconfig-paths/register src/scripts/run-migrations.ts"
},
"dependencies": {
"@edr/api-common": "workspace:*",

View File

@@ -1,15 +1,51 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';
export class AddPostPaymentCompletedColumn1719667261000 implements MigrationInterface {
name = 'AddPostPaymentCompletedColumn1719667261000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE freight.first_mile_deliveries ADD COLUMN IF NOT EXISTS is_post_payment_completed BOOLEAN NOT NULL DEFAULT false;`);
await queryRunner.query(`ALTER TABLE freight.last_mile_deliveries ADD COLUMN IF NOT EXISTS is_post_payment_completed BOOLEAN NOT NULL DEFAULT false;`);
const firstMileTable = await queryRunner.hasTable('freight.first_mile_deliveries');
if (firstMileTable) {
const hasColumn = await queryRunner.hasColumn('freight.first_mile_deliveries', 'is_post_payment_completed');
if (!hasColumn) {
await queryRunner.addColumn(
'freight.first_mile_deliveries',
new TableColumn({
name: 'is_post_payment_completed',
type: 'boolean',
default: false,
isNullable: false,
})
);
}
}
const lastMileTable = await queryRunner.hasTable('freight.last_mile_deliveries');
if (lastMileTable) {
const hasColumn = await queryRunner.hasColumn('freight.last_mile_deliveries', 'is_post_payment_completed');
if (!hasColumn) {
await queryRunner.addColumn(
'freight.last_mile_deliveries',
new TableColumn({
name: 'is_post_payment_completed',
type: 'boolean',
default: false,
isNullable: false,
})
);
}
}
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE freight.last_mile_deliveries DROP COLUMN IF EXISTS is_post_payment_completed;`);
await queryRunner.query(`ALTER TABLE freight.first_mile_deliveries DROP COLUMN IF EXISTS is_post_payment_completed;`);
const lastMileTable = await queryRunner.hasTable('freight.last_mile_deliveries');
if (lastMileTable) {
await queryRunner.dropColumn('freight.last_mile_deliveries', 'is_post_payment_completed');
}
const firstMileTable = await queryRunner.hasTable('freight.first_mile_deliveries');
if (firstMileTable) {
await queryRunner.dropColumn('freight.first_mile_deliveries', 'is_post_payment_completed');
}
}
}