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

Pg Enums #33

Merged
merged 23 commits into from
Jan 3, 2024
Merged

Pg Enums #33

merged 23 commits into from
Jan 3, 2024

Conversation

JuzerShakir
Copy link
Owner

@JuzerShakir JuzerShakir commented Dec 30, 2023

This PR focuses on changing the enum value types, from integer to PostgreSQL enum type. The following field types were changed:

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 the config/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 a hash type, we cannot use the constants as it's an array type. But we will use it as a reference and give the #to_h_titleize_values method to it to return a hash type where the keys will be self & its values will be in a titleized format of self. 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.

  • Define a #to_h_titleize_values to Array class in 3d123d6

Other changes:

  • Fixed the depreciated method Faker#free_email in e4bee27.
  • refactor thaali form in b646eb2.
  • Initiate new instances with default values for the Thaali, Sabeel & Transaction entities in c06efc4, d6b8d68, & d04ff7e which will help remove a lot of redundant code.

@JuzerShakir JuzerShakir marked this pull request as ready for review January 2, 2024 10:41
@JuzerShakir JuzerShakir changed the title Pg enums Pg Enums Jan 3, 2024
@JuzerShakir JuzerShakir merged commit 2b72cd2 into master Jan 3, 2024
1 check passed
@JuzerShakir JuzerShakir deleted the pg-enums branch January 30, 2024 05:50
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.

1 participant