Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

users has a bunch of nullable columns #16442

Open
clokep opened this issue Oct 6, 2023 · 3 comments
Open

users has a bunch of nullable columns #16442

clokep opened this issue Oct 6, 2023 · 3 comments
Labels
A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@clokep
Copy link
Member

clokep commented Oct 6, 2023

Additionally:

  • name is a nullable field (?!?!?!)

With that said, on matrix.org:

matrix=> select count(*) from users;
  count   
══════════
 62887652
(1 row)

Time: 12499.198 ms (00:12.499)
matrix=> select count(*) from users where name IS NULL;
 count 
═══════
     0
(1 row)

Originally posted by @DMRobertson in #16434 (comment)

@reivilibre reivilibre added T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db labels Oct 11, 2023
@reivilibre
Copy link
Contributor

we should migrate this to be NOT NULL as a matter of principle. Thank goodness there aren't any entries with NULL values!

@DMRobertson
Copy link
Contributor

matrix=> \d users
                          Table "matrix.users"
           Column           │   Type   │ Collation │ Nullable │ Default 
════════════════════════════╪══════════╪═══════════╪══════════╪═════════
 name                       │ text     │           │          │ 
 password_hash              │ text     │           │          │ 
 creation_ts                │ bigint   │           │          │ 
 admin                      │ smallint │           │ not null │ 0
 upgrade_ts                 │ bigint   │           │          │ 
 is_guest                   │ smallint │           │ not null │ 0
 appservice_id              │ text     │           │          │ 
 consent_version            │ text     │           │          │ 
 consent_server_notice_sent │ text     │           │          │ 
 user_type                  │ text     │           │          │ 
 deactivated                │ smallint │           │ not null │ 0
 shadow_banned              │ boolean  │           │          │ 
 consent_ts                 │ bigint   │           │          │ 
 approved                   │ boolean  │           │          │ 
 locked                     │ boolean  │           │ not null │ false
Indexes:
    "users_creation_ts" btree (creation_ts)
    "users_lower_name" btree (lower(name))
    "users_name_key" UNIQUE CONSTRAINT, btree (name)
Referenced by:
    TABLE "per_user_experimental_features" CONSTRAINT "per_user_experimental_features_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(name)
    TABLE "users_to_send_full_presence_to" CONSTRAINT "users_to_send_full_presence_to_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(name)

Lots of other surprisingly nullable fields here, e.g. creation_ts.

@clokep clokep changed the title users.name is nullable? users has a bunch of nullable columns Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Database DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

No branches or pull requests

3 participants