Fall back to extracting sequence name from column default

What does this MR do and why?

Update Gitlab::Database::Partitioning::ReplaceTable to try extract sequence name from column's default when pg_get_serial_sequence returns null.

References

Numbered steps to set up and validate the change are strongly suggested.

Example:

  1. Remove ownership for a sequence
    ALTER SEQUENCE uploads_id_seq OWNED BY NONE;
  2. On master
    > Gitlab::Database::Partitioning::ReplaceTable.new(ApplicationRecord.connection, 'uploads', 'uploads_new', 'uploads_archived', 'id').sequence
    => nil
  3. On this branch
    > Gitlab::Database::Partitioning::ReplaceTable.new(ApplicationRecord.connection, 'uploads', 'uploads_new', 'uploads_archived', 'id').sequence
    => "uploads_id_seq"

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading