Clean up schema for table namespaces
From https://gitlab.com/gitlab-com/infrastructure/issues/1709 (private to GitLab employees):
- Wrong data type: ldap_sync_last_update_at should be timestamptz
- Wrong data type: ldap_sync_last_successful_update_at should be timestamptz
- Wrong data type: ldap_sync_last_sync_at should be timestamptz
- Wrong data type: deleted_at should be timestamptz
- Extra default: type default NULL
- Extra default: avatar default NULL
- Missing FK: owner_id -> users (188 entries violate this rule)
- Missing FK: parent_id -> namespaces (1 entry violates this rule, id: 1527422)
- Duplicate data: path seems very similar to name+parent info, plus has two indexes (btree and gin)
- Duplicate data: type column would be more efficient as an enum or integer (mostly NULL, only save ~868 kB)
- Duplicate data: ldap_sync_status column would be more efficient as an enum or integer, save 6MB
- Extra index: index_namespaces_on_created_at - namespaces (created_at) (?)
- Extra index: index_namespaces_on_deleted_at - namespaces (deleted_at)
- Extra index: index_namespaces_on_ldap_sync_last_successful_update_at - namespaces (ldap_sync_last_successful_update_at)
- Extra index: index_namespaces_on_ldap_sync_last_update_at - namespaces (ldap_sync_last_update_at)
- Index on boolean (not very useful): index_namespaces_on_require_two_factor_authentication
- Duplicate data: description and description_html - not possible to have one format which can generate both..?
- Unused constraint: UNIQUE over (parent_id, id) - "id" is primary key and already unique
- ldap_sync_* might be better in another table