Police-Data-Accessibility-Project / data-sources-app

An API and UI for using and maintaining the Data Sources database
MIT License
2 stars 5 forks source link

Change date columns types to timestamp #369

Open EvilDrPurple opened 1 month ago

EvilDrPurple commented 1 month ago

Context

Since updating the last_cached column to have the type timestamp so that we could store more precise times, we should update the rest of the date columns to timestamp as well for more uniformity The only column that comes to mind that should be updated is broken_source_url_as_of but there may be others

Requirements

if key == "last_cached" and value is not None:
    data_dict[key] = value.strftime("%Y-%m-%d %H:%M:%S")
elif isinstance(value, datetime.date):
    data_dict[key] = value.strftime("%Y-%m-%d")

Tests

josh-chamberlain commented 1 month ago

would dates without a time just be set to 00:00:00 in a migration? Do we need to change anything upstream in Airtable?

EvilDrPurple commented 1 month ago

would dates without a time just be set to 00:00:00 in a migration?

Yes! Dates are automatically set to 00:00:00 when converted to timestamp

Do we need to change anything upstream in Airtable?

I imagine eventually, once we merge the v2 database with Airtable (assuming I'm thinking about this correctly)