pet-rescue icon indicating copy to clipboard operation
pet-rescue copied to clipboard

913 add null constraints and update org create service

Open Gabe-Torres opened this issue 6 months ago • 1 comments

🔗 Issue

#913

✍️ Description

This Pr adds null constraints to the Organization model name, email, and slug attributes. Initially, I tried to add the null constraints by simply adding the columns. Rails didn't approve and gave the following error

"Dangerous operation detected #strong_migrations === Setting NOT NULL on an existing column blocks reads and writes while every row is checked"

It then guided me to add a check constraint and validate it in a separate migration. Adding NOT NULL constraints on an existing column can be dangerous in a production environment and can lock the table and block reads and writes, which is why strong_migrations recommended a safer approach.

This will also allow for easier rollbacks if needed.

Also adds:

  • email attribute on Organizations Create Service
  • validation for presence and format for the following organization attributes: name, slug, and email
  • All corresponding test updates

Gabe-Torres avatar Aug 16 '24 19:08 Gabe-Torres