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

update alt_email column on users to be null where it is an empty stri… #845

Open
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

daryanypl
Copy link
Contributor

…ng, and add uniqueness constraint on that column

https://jira.nypl.org/browse/MLN-715

…ng, and add uniqueness constraint on that column
@daryanypl daryanypl self-assigned this Jan 29, 2021

class SetUserAltEmailToNullAndAddUnique < ActiveRecord::Migration[5.0]
def change
execute "UPDATE users SET alt_email=NULL where alt_email=''"
Copy link
Collaborator

Choose a reason for hiding this comment

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

how single quotes saved in alt_email column?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In future again we will get same issue. We have to fix while saving the alt_email.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Currently, we have a unique constraint on that column. So there can be at most only one empty alt_email row for the table. We also have code in the users.rb model file that makes sure alt_email is unique before the user object is persisted to the database.
I've updated the users model to take allowed_blank out for that field just now, so that should finish covering the '' scenario.

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.

None yet

2 participants