Last active
July 9, 2024 15:40
-
-
Save phillipoertel/5adf221030d996f0445ce6b9e3f14d03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# add a db schema migration to add geocoded_at to listings | |
add_column :listings, :geocoded_at, :timestamp, default: nil | |
# add a geocoded? method to the model | |
class Listing < ApplicationRecord | |
def geocoded? | |
read_attribute(:geocoded) || geocoded_at.present? | |
end | |
end | |
# write four unit tests for the above method, testing all four possible combinations of the two attributes. | |
# adjust the geocoding code (service) to only use that method to check for geocoding status | |
# add the data_migrate gem to the gemfile | |
# write a data migration to set geocoded_at to a fixed timestamp (same for all records) where geocoded=1. | |
# See https://github.com/ilyakatz/data-migrate for how to do this | |
# deploy, run schema and data migrations, and check that all was migrated correctly | |
# add migration to drop the unneccessary "geocoded" attribute from listings | |
remove_column :listings, :geocoded | |
# change the geocoded? method to only check for the timestamp (read_attribute(:geocoded) will raise an error) | |
# deploy & all good |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment