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

Conversation

@Matelz
Copy link
Contributor

@Matelz Matelz commented May 20, 2025

This pull request introduces significant changes to the database schema, database layer, and order handling logic, along with updates to the toolset for order management. The changes include the addition of new database tables and enums, refactoring of database interfaces and implementations, and the introduction of a new handler for managing orders. Below is a summary of the most important changes grouped by theme.

Database Schema and Configuration Updates:

  • Added new tables (order, product, order_item) and an enum (orderStatusEnum) to support order management. These include fields for relationships, timestamps, and additional metadata. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-0418d6df92492cd6ccd0cdc243d498a3640952877ebd62c6373329d7bf38460eL1-R7), [[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-0418d6df92492cd6ccd0cdc243d498a3640952877ebd62c6373329d7bf38460eR33-R61))
  • Updated the drizzle.config.ts file to reflect the new schema file location (src/database/schema.ts). ([drizzle.config.tsL5-R5](https://github.com/PoliEats/Backend/pull/4/files#diff-d4e1c765f5d43acb9c59d87b520418289031da3fe52f5031041502b1250509c8L5-R5))

Database Layer Enhancements:

  • Created a new PostgresDatabase class implementing IDatabase, with methods for CRUD operations and advanced query capabilities. ([src/database/PostgresDatabase.tsR1-R83](https://github.com/PoliEats/Backend/pull/4/files#diff-84d843dff943834903b3db9f368080eb8efa5d2266ea23db0d5782644e695e1bR1-R83))
  • Updated the MockDatabase class to improve ID generation logic and added debug logging for query results. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-76a9b8dfe33fdeb6e160cac0c903fc1e9c010c47d1a49d0009665fecec593aaeL32-R42), [[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-76a9b8dfe33fdeb6e160cac0c903fc1e9c010c47d1a49d0009665fecec593aaeR83-R85), [[3]](https://github.com/PoliEats/Backend/pull/4/files#diff-76a9b8dfe33fdeb6e160cac0c903fc1e9c010c47d1a49d0009665fecec593aaeR100-R104))
  • Refactored the IDatabase interface to align with changes in the drizzle-orm library. ([src/interfaces/IDatabase.tsL28-R28](https://github.com/PoliEats/Backend/pull/4/files#diff-c5ab488a5fe71a9432aa7be6662769278b210569c9a4366637859549d6f0b570L28-R28))

Order Handling Logic:

  • Introduced a new OrderHandler class to manage order creation, retrieval, updates, and deletion with proper error handling and user validation. ([src/handlers/OrderHandler.tsR1-R244](https://github.com/PoliEats/Backend/pull/4/files#diff-d2c332f37ea9ab2a7ceb48301f9eb978eb502720c928edd7829150832fa3dc5fR1-R244))
  • Added IOrder and IOrderItem types to define the structure of orders and their items. ([src/interfaces/IOrder.tsR1-R17](https://github.com/PoliEats/Backend/pull/4/files#diff-9f4a69f396d7d638a094a4c13bbcd39eb1b5fcf540927391b12d0b48cd47ce8bR1-R17))

Toolset and Integration Updates:

  • Updated the createOrder tool to integrate with the new OrderHandler for order creation, replacing the previous in-memory logic with database-backed functionality. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-94f1465c60f3e73761ee6a66e6ff15dbebe68291463b94f4b7d8737401e991deL3-L53), [[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-94f1465c60f3e73761ee6a66e6ff15dbebe68291463b94f4b7d8737401e991deL75-R44), [[3]](https://github.com/PoliEats/Backend/pull/4/files#diff-94f1465c60f3e73761ee6a66e6ff15dbebe68291463b94f4b7d8737401e991deL108-R97))
  • Modified the model.ts file to include the getOrders tool and updated the message format to include user details. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-808e86d7790a8533bc72e3c293111131e03375a5a42dc868fb175b617ed58a70L4-R11), [[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-808e86d7790a8533bc72e3c293111131e03375a5a42dc868fb175b617ed58a70L26-R28))

Environment and Configuration Cleanup:

  • Removed sensitive environment variables and configuration details from the .env file to enhance security. ([.envL1-L6](https://github.com/PoliEats/Backend/pull/4/files#diff-e9cbb0224c4a3d23a6019ba557e0cd568c1ad5e1582ff1e335fb7d99b7a1055dL1-L6))

@Matelz Matelz self-assigned this May 20, 2025
@Matelz Matelz added the enhancement New feature or request label May 20, 2025
@Matelz Matelz merged commit 9854c7b into main May 20, 2025
1 check failed
@Matelz Matelz deleted the feature/order-service branch May 20, 2025 22:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant