Clean up schema for table ci_pipelines

From https://gitlab.com/gitlab-com/infrastructure/issues/1709 (private to GitLab employees):

  • Wrong data type: created_at should be timestamptz
  • Wrong data type: updated_at should be timestamptz
  • Wrong data type: committed_at should be timestamptz
  • Wrong data type: started_at should be timestamptz
  • Wrong data type: finished_at should be timestamptz
  • Wrong data type: sha, before_sha - should be bytea (binary in Rails), save ~221MB
  • Missing constraint: status NOT NULL (?) (800 entries violate this rule)
  • Missing constraint: sha NOT NULL (?) (175 entries violate this rule)
  • Duplicate data: status would be more efficient as an enum or integer (or smaller), save ~82MB
  • Duplicate data: fields similar to status appear to be: ref
    • ref is the Git ref (= a SHA), so we can't do much with this at this point
  • Duplicate data: duration = finished_at - started_at
    • Nuke this column and just generate it in the Ruby code / SQL queries
Edited by Yorick Peterse