Skip to content

Conversation

@martindolores
Copy link

Description

  • Create 'tutor_times' table and 'TutorTime' model for Tutor Times Feature

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  1. In your terminal, change directory to doubtfire-api - if you are in doubtfire-deploy, simply run the following:
cd doubtfire-api
  1. Run the following to apply pending migrations and update your database schema:
rails db:migrate
  1. Run the following to access the Ruby shell:
rails console
  1. Finally, confirm that the tutor_times table has been added by ensuring all columns matches the migration. You can run this in the Ruby shell to return all the columns of the table:
TutorTime.column_names

image

Migration File:
image

Checklist

If involving code

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation - There is existing ticket in Backlog to update documentation for Backend - Tutor Times
  • My changes generate no new warnings

Folders and Files Added/Modified

  • Added:
    • app/models/tutor_time.rb
    • db/migrate/20250324073540_create_tutor_times.rb
  • Modified:
    • db/schema.rb

@martindolores martindolores changed the title - Create 'tutor_times' table and 'TutorTime' model Feature/Create 'tutor_times' table and 'TutorTime' Model Mar 24, 2025
Copy link

@samindiii samindiii left a comment

Choose a reason for hiding this comment

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

First of all, great work on the migration and model :)

I have tested your code and can verify that it works as intended, based off the ticket. Additionally, I have reviewed your code and suggested some minor adjustments to enhance code quality.

Once you have reviewed my comments, please inform me so that I can approve the changes.

@martindolores
Copy link
Author

@samindiii - changes have now been applied 🙂

Copy link

@samindiii samindiii left a comment

Choose a reason for hiding this comment

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

Hey Martin! I'm happy with the changes and will be approving this!

Copy link

@b0ink b0ink left a comment

Choose a reason for hiding this comment

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

Hey @martindolores

I was able to pull your changes and migrate successfully, and confirmed it worked by retrieving the column names of the new table - just one note regarding the reference to the tutor in your table

class CreateTutorTimes < ActiveRecord::Migration[7.1]
def change
create_table :tutor_times do |t|
t.references :user, null: false, foreign_key: { on_delete: :cascade }
Copy link

Choose a reason for hiding this comment

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

Is the "user" here a tutor (staff) that is assigned within a unit? You could probably reference the staff from the unit_roles table instead, implying that we're referencing staff here and not students

Copy link
Author

Choose a reason for hiding this comment

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

Hey @b0ink :), I believe this would be a tutor, I can push up a change shortly.

Im assuming I would also have to change the model then too right to include the following:

class TutorTime < ApplicationRecord
...
  belongs_to :unit_role
  has_one :user, through: :unit_role
....

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.

4 participants