Skip to content
This repository was archived by the owner on Jul 14, 2024. It is now read-only.

Commit

Permalink
feat: add entity manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielDeSouzza committed Jun 1, 2024
1 parent 4d491b1 commit 943f7fa
Show file tree
Hide file tree
Showing 56 changed files with 937 additions and 1,215 deletions.
2 changes: 1 addition & 1 deletion .docker/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

npx prisma db push --force-reset
npx prisma db push

if [ $? -eq 0 ]; then
echo "Database updated successfully. Running the server 🚀"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modul

COPY --chown=node:node . .

RUN pnpm build

ENV NODE_ENV production

RUN pnpm fetch --prod
Expand All @@ -40,6 +38,8 @@ RUN pnpm install

RUN pnpm prisma generate

RUN pnpm build

USER node

# PRODUCTION
Expand Down
50 changes: 21 additions & 29 deletions prisma/dbml/schema.dbml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ Table vehicles {
model_id String [not null]
OutsourcedTransportVehicle outsourced_transport_vehicle
OrderProcessing order_procesing
CompletedOrders completed_orders
}

Table vehicle_models {
Expand Down Expand Up @@ -162,7 +161,6 @@ Table outsourced_vehicles {
updated_by String [not null]
Vehicle vehicles [not null]
vehicle_id String [unique, not null]
order_processing_id String
OutsourcedDriver outsourced_drivers
}

Expand Down Expand Up @@ -267,6 +265,7 @@ Table own_drivers {
updated_by String [not null]
NaturalPerson natural_people [not null]
natural_person_id String [not null]
OrderProcessing order_procesing [not null]
}

Table natural_people {
Expand Down Expand Up @@ -412,7 +411,6 @@ Table physical_orders {
CarrierCompany carrier_companies [not null]
order_processing_id String
OrderProcessing order_procesing
CompletedOrders completed_orders
completedOrdersId String
PhysicalCustomerQuoteTable physical_customer_quote [not null]
quote_table_id String [not null]
Expand Down Expand Up @@ -627,7 +625,6 @@ Table legal_orders {
carrier_id String [not null]
CarrierCompany carrier_companies [not null]
OutsourcedTransportCompanyContract OutsourcedTransportCompanyContract
CompletedOrders completed_orders
completed_orders_id String
LegalClientCte legal_client_cte
FreightExpenses freight_expenses [not null]
Expand Down Expand Up @@ -655,16 +652,31 @@ Table order_procesing {
total_distance Float [not null]
total_spend_liters Float [not null]
total_spending_money Float [not null]
status String [not null, default: 'created']
status String [not null]
start_at DateTime [not null]
end_at DateTime
updated_at DateTime [not null]
created_at DateTime [not null]
created_by String [not null]
updated_by String [not null]
driver_id String [not null]
OwnDriver own_drivers
PhysicalCustomerOrder physical_orders [not null]
LegalClientOrder legal_orders [not null]
Incident Incident [not null]
Manifest Manifest [not null]
}

Table Manifest {
id String [pk]
order_processing_id String [not null]
OrderProcessing order_procesing [not null]
manifest_url String
emission_date DateTime [not null]
number String [not null]
serie String [not null]
num_protocol String [not null]
acess_key String [not null]
}

Table Incident {
Expand All @@ -682,24 +694,6 @@ Table Incident {
updated_at DateTime [not null]
}

Table completed_orders {
id String [pk]
order_processing_number String [not null]
vehicle_id String [unique, not null]
Vehicle vehicles [not null]
total_distance Float [not null]
total_spend_liters Float [not null]
total_spending_money Float [not null]
start_at DateTime [not null]
end_at DateTime [not null]
updated_at DateTime [not null]
created_at DateTime [not null]
created_by String [not null]
updated_by String [not null]
PhysicalCustomerOrder physical_orders [not null]
LegalClientOrder legal_orders [not null]
}

Table freight_expenses {
id String [pk]
expense_name String [not null]
Expand Down Expand Up @@ -884,8 +878,6 @@ Ref: physical_orders.carrier_id > carrier_companies.id

Ref: physical_orders.order_processing_id > order_procesing.id

Ref: physical_orders.completedOrdersId > completed_orders.id

Ref: physical_orders.quote_table_id > physical_customer_quote.id

Ref: physical_customer_cte.order_id - physical_orders.id
Expand Down Expand Up @@ -952,8 +944,6 @@ Ref: legal_orders.order_processing_id > order_procesing.id

Ref: legal_orders.carrier_id > carrier_companies.id

Ref: legal_orders.completed_orders_id > completed_orders.id

Ref: ciots_for_legal_clients.legal_contract_id > legal_Contracts.id

Ref: ciots_for_legal_clients.created_by > users.id
Expand All @@ -962,14 +952,16 @@ Ref: ciots_for_legal_clients.updated_by > users.id

Ref: order_procesing.vehicle_id - vehicles.id

Ref: order_procesing.driver_id > own_drivers.id

Ref: Manifest.order_processing_id > order_procesing.id

Ref: Incident.order_process_id > order_procesing.id

Ref: Incident.created_by > users.id

Ref: Incident.updated_by > users.id

Ref: completed_orders.vehicle_id - vehicles.id

Ref: freight_expenses.legal_client_order_id > legal_orders.id

Ref: freight_expenses.physical_customer_id > physical_orders.id
Expand Down
46 changes: 46 additions & 0 deletions prisma/migrations/20240530173927_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Warnings:
- You are about to drop the column `order_processing_id` on the `outsourced_vehicles` table. All the data in the column will be lost.
- You are about to drop the `completed_orders` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `driver_id` to the `order_procesing` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "completed_orders" DROP CONSTRAINT "completed_orders_vehicle_id_fkey";

-- DropForeignKey
ALTER TABLE "legal_orders" DROP CONSTRAINT "legal_orders_completed_orders_id_fkey";

-- DropForeignKey
ALTER TABLE "physical_orders" DROP CONSTRAINT "physical_orders_completedOrdersId_fkey";

-- AlterTable
ALTER TABLE "order_procesing" ADD COLUMN "driver_id" TEXT NOT NULL,
ALTER COLUMN "status" DROP DEFAULT;

-- AlterTable
ALTER TABLE "outsourced_vehicles" DROP COLUMN "order_processing_id";

-- DropTable
DROP TABLE "completed_orders";

-- CreateTable
CREATE TABLE "Manifest" (
"id" TEXT NOT NULL,
"order_processing_id" TEXT NOT NULL,
"manifest_url" TEXT,
"emission_date" TIMESTAMP(3) NOT NULL,
"number" TEXT NOT NULL,
"serie" TEXT NOT NULL,
"num_protocol" TEXT NOT NULL,
"acess_key" TEXT NOT NULL,

CONSTRAINT "Manifest_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "order_procesing" ADD CONSTRAINT "order_procesing_driver_id_fkey" FOREIGN KEY ("driver_id") REFERENCES "own_drivers"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Manifest" ADD CONSTRAINT "Manifest_order_processing_id_fkey" FOREIGN KEY ("order_processing_id") REFERENCES "order_procesing"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
63 changes: 27 additions & 36 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ model Vehicle {
model_id String
OutsourcedTransportVehicle OutsourcedTransportVehicle?
OrderProcessing OrderProcessing?
CompletedOrders CompletedOrders?
@@map("vehicles")
}
Expand Down Expand Up @@ -201,14 +200,13 @@ model OutsourcedVehicle {
created_at DateTime @default(now())
updated_at DateTime @default(now())
CreatedBy User? @relation("created_by", fields: [created_by], references: [id])
created_by String
UpdatedBy User? @relation("updated_by", fields: [updated_by], references: [id])
updated_by String
Vehicle Vehicle @relation(fields: [vehicle_id], references: [id])
vehicle_id String @unique
order_processing_id String?
OutsourcedDriver OutsourcedDriver?
CreatedBy User? @relation("created_by", fields: [created_by], references: [id])
created_by String
UpdatedBy User? @relation("updated_by", fields: [updated_by], references: [id])
updated_by String
Vehicle Vehicle @relation(fields: [vehicle_id], references: [id])
vehicle_id String @unique
OutsourcedDriver OutsourcedDriver?
@@map("outsourced_vehicles")
}
Expand Down Expand Up @@ -324,12 +322,13 @@ model OwnDriver {
created_at DateTime @default(now())
updated_at DateTime @default(now())
CreatedBy User? @relation("created_by", fields: [created_by], references: [id])
CreatedBy User? @relation("created_by", fields: [created_by], references: [id])
created_by String
UpdatedBy User? @relation("updated_by", fields: [updated_by], references: [id])
UpdatedBy User? @relation("updated_by", fields: [updated_by], references: [id])
updated_by String
NaturalPerson NaturalPerson @relation(fields: [natural_person_id], references: [id])
NaturalPerson NaturalPerson @relation(fields: [natural_person_id], references: [id])
natural_person_id String
OrderProcessing OrderProcessing[]
@@map("own_drivers")
}
Expand Down Expand Up @@ -489,7 +488,6 @@ model PhysicalCustomerOrder {
CarrierCompany CarrierCompany @relation(fields: [carrier_id], references: [id])
order_processing_id String?
OrderProcessing OrderProcessing? @relation(fields: [order_processing_id], references: [id])
CompletedOrders CompletedOrders? @relation(fields: [completedOrdersId], references: [id])
completedOrdersId String?
PhysicalCustomerQuoteTable PhysicalCustomerQuoteTable @relation(fields: [quote_table_id], references: [id])
quote_table_id String
Expand Down Expand Up @@ -724,7 +722,6 @@ model LegalClientOrder {
CarrierCompany CarrierCompany @relation(fields: [carrier_id], references: [id])
OutsourcedTransportCompanyContract OutsourcedTransportCompanyContract?
CompletedOrders CompletedOrders? @relation(fields: [completed_orders_id], references: [id])
completed_orders_id String?
LegalClientCte LegalClientCte?
FreightExpenses FreightExpenses[]
Expand Down Expand Up @@ -756,20 +753,35 @@ model OrderProcessing {
total_distance Float
total_spend_liters Float
total_spending_money Float
status String @default("created")
status String
start_at DateTime
end_at DateTime?
updated_at DateTime
created_at DateTime
created_by String
updated_by String
driver_id String
OwnDriver OwnDriver? @relation(fields: [driver_id], references: [id])
PhysicalCustomerOrder PhysicalCustomerOrder[]
LegalClientOrder LegalClientOrder[]
Incident Incident[]
Manifest Manifest[]
@@map("order_procesing")
}

model Manifest {
id String @id @default(uuid())
order_processing_id String
OrderProcessing OrderProcessing @relation(fields: [order_processing_id], references: [id])
manifest_url String?
emission_date DateTime
number String
serie String
num_protocol String
acess_key String
}

model Incident {
id String @id @default(uuid())
description String
Expand All @@ -786,27 +798,6 @@ model Incident {
updated_at DateTime
}

model CompletedOrders {
id String @id @default(uuid())
order_processing_number String
vehicle_id String @unique
Vehicle Vehicle @relation(fields: [vehicle_id], references: [id])
total_distance Float
total_spend_liters Float
total_spending_money Float
start_at DateTime
end_at DateTime
updated_at DateTime
created_at DateTime
created_by String
updated_by String
PhysicalCustomerOrder PhysicalCustomerOrder[]
LegalClientOrder LegalClientOrder[]
@@map("completed_orders")
}

model FreightExpenses {
id String @id @default(uuid())
expense_name String
Expand Down
4 changes: 2 additions & 2 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin
import { CarrierCompanyModule } from 'infra/graphql/entities/CarrierCompanyGraphql/CarrierCompany.module';
import { CiotForLegalClientModule } from 'infra/graphql/entities/CiotForLegalClientGraphql/CiotForLegalClient.module';
import { CompanyVehicleModule } from 'infra/graphql/entities/CompanyVehicle/CompanyVehicle.module';
import { CompletedOrdersModule } from 'infra/graphql/entities/CompletedOrdersGraphql/CompletedOrders.module';
import { ContractOutsoucedDriverModule } from 'infra/graphql/entities/ContractOutsourcedDriverGraphql/ContractOutsoucedDriver.module';
import { FreightExpenseModule } from 'infra/graphql/entities/FreightExpenseGraphql/FreightExpense.module';
import { CtePdfModule } from 'infra/graphql/entities/GenerateCtePdfGraphql/CtePdf.module';
Expand All @@ -24,6 +23,7 @@ import { LegalClientQuoteTableModule } from 'infra/graphql/entities/LegalClientQ
import { LegalContractModule } from 'infra/graphql/entities/LegalContractGraphql/LegalContract.module';
import { MaintenanceCompanyModule } from 'infra/graphql/entities/MaintenanceCompanyGraphql/MaintenanceCompany.module';
import { MaintenanceModule } from 'infra/graphql/entities/MaintenanceGraphql/Maintenance.module';
import { ManifestModule } from 'infra/graphql/entities/ManifestGraphql/Manifest.module';
import { OrderProcessingModule } from 'infra/graphql/entities/OrderProcessingGraphql/OrderProcessing.module';
import { OutsourcedDriverModule } from 'infra/graphql/entities/OutsourcedDriverGraphql/OutsourcedDriver.module';
import { OutsourcedTransportCompanyContractModule } from 'infra/graphql/entities/OutsourcedTransportCompanyContractGraphql/OutsourcedTransportCompanyContract.module';
Expand Down Expand Up @@ -91,7 +91,6 @@ import { AuthModule } from 'infra/guard/auth.module';
SenderModule,
LegalClientQuoteTableModule,
PhysicalCustomerQuoteTableModule,
CompletedOrdersModule,
PhysicalCustomerCteModule,
LegalClientCteModule,
FreightExpenseModule,
Expand All @@ -100,6 +99,7 @@ import { AuthModule } from 'infra/guard/auth.module';
MaintenanceCompanyModule,
MaintenanceModule,
IncidentModule,
ManifestModule,
],
})
export class AppModule {}
16 changes: 0 additions & 16 deletions src/app/dtos/CompletedOrdersDto/CreateCompletedOrdersDto.ts

This file was deleted.

Loading

0 comments on commit 943f7fa

Please sign in to comment.