Clean up schema for table identities

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
  • Missing constraint: created_at NOT NULL (29543 entries violate this rule)
  • Missing constraint: updated_at NOT NULL (29543 entries violate this rule)
  • Missing constraint: provider NOT NULL
  • Missing constraint: user_id NOT NULL
  • Missing constraint: extern_uid NOT NULL
  • Missing FK: user_id -> users
  • Duplicate data: provider could be 4-byte integer, save 5MB
  • Missing constraint: secondary_extern_uid NOT NULL (needs to be non-null for unique index)
  • Missing constraint: UNIQUE (extern_uid, provider, user_id, secondary_extern_uid) - 2 extern UIDs violate this rule (Mhanicos, j_balesteri)
  • (is including user_id in the unique constraint required? can a given external_uid map to multiple user_ids?)
  • Missing index: extern_uid, provider (?) -- may not be necessary if UNIQUE constraint is added