Skip to content

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:

  1. Removing use of the deprecated add_column_with_default method
  2. 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.
  3. 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 as read_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

  1. Create a migration with:

    def up
      add_timestamps_with_timezone(:packages_packages, columns: [:read_at])
    end
  2. 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.

Related to #345196 (closed)

Merge request reports