                           Table "public.users"
    Column     |           Type           | Collation | Nullable | Default 
---------------+--------------------------+-----------+----------+---------
 id            | uuid                     |           | not null | 
 username      | text                     |           | not null | 
 display_name  | text                     |           | not null | 
 password_hash | text                     |           | not null | 
 created_at    | timestamp with time zone |           | not null | now()
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)
    "users_username_key" UNIQUE CONSTRAINT, btree (username)
Referenced by:
    TABLE "chat_members" CONSTRAINT "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
    TABLE "messages" CONSTRAINT "messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id)
    TABLE "sessions" CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE

                          Table "public.chats"
   Column   |           Type           | Collation | Nullable | Default 
------------+--------------------------+-----------+----------+---------
 id         | uuid                     |           | not null | 
 title      | text                     |           | not null | 
 created_at | timestamp with time zone |           | not null | now()
Indexes:
    "chats_pkey" PRIMARY KEY, btree (id)
Referenced by:
    TABLE "chat_members" CONSTRAINT "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
    TABLE "messages" CONSTRAINT "messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE

           Table "public.chat_members"
 Column  | Type | Collation | Nullable | Default 
---------+------+-----------+----------+---------
 chat_id | uuid |           | not null | 
 user_id | uuid |           | not null | 
Indexes:
    "chat_members_pkey" PRIMARY KEY, btree (chat_id, user_id)
Foreign-key constraints:
    "chat_members_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
    "chat_members_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE

                        Table "public.messages"
   Column   |           Type           | Collation | Nullable | Default 
------------+--------------------------+-----------+----------+---------
 id         | uuid                     |           | not null | 
 chat_id    | uuid                     |           | not null | 
 sender_id  | uuid                     |           | not null | 
 text       | text                     |           | not null | 
 created_at | timestamp with time zone |           | not null | now()
Indexes:
    "messages_pkey" PRIMARY KEY, btree (id)
    "idx_messages_chat_covering" btree (chat_id, created_at, id) INCLUDE (sender_id, text)
    "idx_messages_chat_created_id" btree (chat_id, created_at, id)
Foreign-key constraints:
    "messages_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
    "messages_sender_id_fkey" FOREIGN KEY (sender_id) REFERENCES users(id)

                        Table "public.sessions"
   Column   |           Type           | Collation | Nullable | Default 
------------+--------------------------+-----------+----------+---------
 token      | text                     |           | not null | 
 user_id    | uuid                     |           | not null | 
 expires_at | timestamp with time zone |           | not null | 
 created_at | timestamp with time zone |           | not null | now()
Indexes:
    "sessions_pkey" PRIMARY KEY, btree (token)
    "idx_sessions_expires" btree (expires_at)
    "idx_sessions_user" btree (user_id)
Foreign-key constraints:
    "sessions_user_id_fkey" FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE

                    Index "public.idx_messages_chat_created_id"
   Column   |           Type           | Key? | Definition | Storage | Stats target 
------------+--------------------------+------+------------+---------+--------------
 chat_id    | uuid                     | yes  | chat_id    | plain   | 
 created_at | timestamp with time zone | yes  | created_at | plain   | 
 id         | uuid                     | yes  | id         | plain   | 
btree, for table "public.messages"

