-
Notifications
You must be signed in to change notification settings - Fork 0
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
Pg Enums #33
Merged
Merged
Pg Enums #33
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…` to return hash
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR focuses on changing the enum value types, from
integer
to PostgreSQLenum
type. The following field types were changed:sabeel#apartment
in 46ca139.thaali.size
in daf6152.transaction.mode
in 86040c1.These changes have made it easier to later add values to these as a migration rather than assigning it to a constant
array
type where adding new values in between would lead to inconsistent data and errors.The
APARTMENTS
,SIZES
,MODES
&ROLES
constants defined in theconfig/initializers/constants.rb
file are now defined in their respective classes and will be accessible via their namespace:Sabeel::APARTMENTS
.Thaali::SIZES
.Transaction::MODES
.Role::NAMES
.Since the
enum
type needs to be set as ahash
type, we cannot use the constants as it's anarray
type. But we will use it as a reference and give the#to_h_titleize_values
method to it to return ahash
type where the keys will beself
& its values will be in a titleized format ofself
. This way we can add more values to the constant array regardless of which index we instantiate them in and make sure we don't have any duplicates.#to_h_titleize_values
to Array class in 3d123d6Other changes:
Faker#free_email
in e4bee27.Thaali
,Sabeel
&Transaction
entities in c06efc4, d6b8d68, & d04ff7e which will help remove a lot of redundant code.