Update `add_timestamps_with_timezone` helper
🔬 What does this MR do and why?
The add_timestamps_with_timezone
is out of date. This MR updates the helper by:
- Removing use of the deprecated
add_column_with_default
method - Removing the transaction check
add_column_with_default
is no longer used and we do not need to disable the transaction when adding default values anymore. - Changes the validation on column name to allow any column name ending in
_at
. The existing list seemed overly restrictive, preventing using this helper for adding columns such asread_at
,processed_at
,accessed_at
.
Question for groupdatabase
Should I be updating the helper as I am doing here, or should I leave it and add the updated version to lib/gitlab/database/migration_helpers/v2.rb
?
📷 Screenshots or screen recordings
N/A
How to set up and validate locally
-
Create a migration with:
def up add_timestamps_with_timezone(:packages_packages, columns: [:read_at]) end
-
Run the migration. It should complete successfully.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #345196 (closed)