Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add species to pets table and set up enum in the pet model #233

Merged
merged 8 commits into from
Oct 6, 2023

Conversation

jadekstewart3
Copy link
Collaborator

🔗 Issue

#222

✍️ Description

Added species column to pets table, and setup species enum within the pets model.

📷 Screenshots/Demos

Screenshot 2023-10-03 at 2 16 30 PM

Screenshot 2023-10-03 at 2 16 43 PM

@jadekstewart3 jadekstewart3 requested review from edwinthinks, kasugaijin, marlena-b and nsiwnf and removed request for marlena-b October 3, 2023 20:19
@@ -0,0 +1,5 @@
class AddSpecies2Pets < ActiveRecord::Migration[7.0]
def change
add_column :pets, :species, :integer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
add_column :pets, :species, :integer
add_column :pets, :species, :integer, null: false

Adding this null: false prevents at the database level from allowing rows without the species defined. Helps keep data more accurate in case of issues. This comes especially helpful if validations get skipped

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jadekstewart3 in case you missed this comment :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@edwinthinks I totally did! Thank you, I'll get that updated:)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jadekstewart3 I think the schema.rb file was not updated with null: false. Easiest way to regenerate it is to run rails db:rollback and rails db:migrate :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Ptrboro Oh heck! Thank you!

@@ -31,6 +31,7 @@ class Pet < ApplicationRecord
has_many :adopter_applications, dependent: :destroy
has_one :match, dependent: :destroy
has_many_attached :images
enum species: ["dog", "cat"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@nsiwnf nsiwnf linked an issue Oct 4, 2023 that may be closed by this pull request
Copy link
Collaborator

@edwinthinks edwinthinks left a comment

Choose a reason for hiding this comment

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

LGTM!

@edwinthinks edwinthinks merged commit 615563f into main Oct 6, 2023
3 checks passed
@edwinthinks edwinthinks deleted the add_species branch October 6, 2023 12:12
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.

Add "species" to pet model
3 participants