Skip to content

F4KRP-47 Create Routes and Route Stops Table#16

Merged
eddywang4340 merged 7 commits intomainfrom
eddy/create-routes-db
Oct 11, 2025
Merged

F4KRP-47 Create Routes and Route Stops Table#16
eddywang4340 merged 7 commits intomainfrom
eddy/create-routes-db

Conversation

@eddywang4340
Copy link
Contributor

@eddywang4340 eddywang4340 commented Oct 8, 2025

Notion ticket link

F4KRP-47

Implementation description

  • Created routes table (with fields: route_id, name, notes, length, route_stops)
  • Created route stops table (with fields: route_id, location_id, stop_number, route)
  • Created a relationship between two tables. For example, given a route you can easily access all of its stops. Also, given a stop, you can easily access which route it belongs to.
  • If you delete a route, it will delete all of the route_stops that belong to that route (not sure if we want this)

Steps to test

What should reviewers focus on?

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@eddywang4340 eddywang4340 self-assigned this Oct 8, 2025
@eddywang4340 eddywang4340 requested a review from ColinToft October 9, 2025 00:19
@ColinToft ColinToft requested review from a team and Copilot October 9, 2025 02:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements database models for a route management system by creating Route and RouteStop tables with their respective SQLModel classes. The implementation establishes a one-to-many relationship between routes and route stops with cascade deletion behavior.

  • Created Route model with fields for route metadata (name, notes, length) and relationship to route stops
  • Created RouteStop model with foreign key references and stop sequencing capability
  • Added proper model registration in the database initialization module

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
backend/python/app/models/routes.py Defines Route model with base, table, and API models including relationship to route stops
backend/python/app/models/route_stops.py Defines RouteStop model with foreign key relationships and stop sequencing
backend/python/app/models/init.py Registers new models for database initialization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ColinToft ColinToft requested review from a team, ColinToft and Jam-Cai and removed request for a team and ColinToft October 9, 2025 02:28
Copy link
Collaborator

@ColinToft ColinToft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@eddywang4340 eddywang4340 merged commit fcfb4e4 into main Oct 11, 2025
1 check passed
ColinToft pushed a commit that referenced this pull request Oct 13, 2025
* added routes table

* added route_stops table

* added imports to app

* fixed linter issues

* fixed formatting errors

* fixed import

* removed route_group_id
landont168 added a commit that referenced this pull request Oct 13, 2025
* Add DriverAssignment schema (#9)

* Add driver_assignment schema

* Register model with SQLModel

* Update foreign keys to point to correct PK fields

* Update tablename

* F4KRP-19 | Add locations table (#10)

* add `Location` model and `locations` table

* Create location_groups schema + update route (#7)

* Create location_groups schema

* Fix linting errors in location_groups.py and __init__.py

* Create location_group service

* Implement PATCH /location-group/{id} route

* Fix formating

* Add num_locations field

* Migrate num_locations to computer property

* Update backend/python/app/models/location_group.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update backend/python/app/models/location_group.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Colin Toft <47548563+ColinToft@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Implemented Driver History Model (#11)

* Implemented Driver History Model

* Fixed Lint Issues

* Addressed Comments

* [F4KRP-85] Create jobs table

[F4KRP-85] Create jobs table (#12)

* Fix job import

* create admin info table (#13)

* admin info table

* fixed formatting and linting issues

* implemented all code review comments

* Merge branch 'database-schemas' into chloe/admin-info-table

* fixed formatting and linting issues

* Merge branch 'database-schemas' into chloe/admin-info-table

* fix linting and formatting

* Merge branch 'database-schemas' into chloe/admin-info-table

* fix formating errors

* feat(models): add RouteGroup models and table definition (#18)

* feat(models): add RouteGroup models and table definition

* test-commit
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>

* test

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>

* tested patch and working, need to fix the response (#22)

* done

* applied copilot changes

* removing unintended changes

* updates to init

* ?

* ?

* ?

* Revert all __init__.py files to match database-schemas branch

* work?

---------

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
Co-authored-by: Colin Toft <47548563+ColinToft@users.noreply.github.com>

* Pranav/create drivers (#17)

* implement base classes for drivers

* fixed lint issues

* reformat driver class

* use base model

* use emailStr for drivers

---------

Co-authored-by: Colin Toft <47548563+ColinToft@users.noreply.github.com>

* F4KRP-47 Create Routes and Route Stops Table (#16)

* added routes table

* added route_stops table

* added imports to app

* fixed linter issues

* fixed formatting errors

* fixed import

* removed route_group_id

* Create location_groups schema + update route (#7)

* Create location_groups schema

* Fix linting errors in location_groups.py and __init__.py

* Create location_group service

* Implement PATCH /location-group/{id} route

* Fix formating

* Add num_locations field

* Migrate num_locations to computer property

* Update backend/python/app/models/location_group.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update backend/python/app/models/location_group.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Colin Toft <47548563+ColinToft@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* [F4KRP-85] Create jobs table

[F4KRP-85] Create jobs table (#12)

* Fix job import

* create admin info table (#13)

* admin info table

* fixed formatting and linting issues

* implemented all code review comments

* Merge branch 'database-schemas' into chloe/admin-info-table

* fixed formatting and linting issues

* Merge branch 'database-schemas' into chloe/admin-info-table

* fix linting and formatting

* Merge branch 'database-schemas' into chloe/admin-info-table

* fix formating errors

* feat(models): add RouteGroup models and table definition (#18)

* feat(models): add RouteGroup models and table definition

* test-commit
Co-authored-by: Yujie Meng <yujiemengca@gmail.com>

* test

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>

* tested patch and working, need to fix the response (#22)

* done

* applied copilot changes

* removing unintended changes

* updates to init

* ?

* ?

* ?

* Revert all __init__.py files to match database-schemas branch

* work?

---------

Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
Co-authored-by: Colin Toft <47548563+ColinToft@users.noreply.github.com>

* Prep for migrations

* migrate db

* refactor validate phone function

* Update backend/python/app/services/implementations/driver_service.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix driver date

* delete import

* fix formatting

* fix typing in migration file

---------

Co-authored-by: Hy Lac <121268118+kingMonkeh@users.noreply.github.com>
Co-authored-by: Landon Trinh <landon.trinh@icloud.com>
Co-authored-by: James <66389450+Jam-Cai@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: David Lu <151972620+ludavidca@users.noreply.github.com>
Co-authored-by: Kerushani Sivaneswaran <99515111+Kerushani@users.noreply.github.com>
Co-authored-by: ChloeW125 <139719503+ChloeW125@users.noreply.github.com>
Co-authored-by: Tq <tqmeng123@gmail.com>
Co-authored-by: Yujie Meng <192458226+Yujie-Meng@users.noreply.github.com>
Co-authored-by: Yujie <yujiemengca@gmail.com>
Co-authored-by: Pranav Gopinath <125942307+PranavGopinath@users.noreply.github.com>
Co-authored-by: Eddy <60328364+eddywang4340@users.noreply.github.com>
Co-authored-by: Landon Trinh <111808279+landont168@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants