This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
# Чистая схема PostgreSQL, ключи и индексы
|
||||
|
||||
Дата сбора: `2026-10-01T17:33:15.537043+00:00`.
|
||||
|
||||
Команды выполняются в корне репозитория, Linux/WSL. Контекст Compose: `COMPOSE_PROJECT_NAME=messenger-evidence-final-20261001-02`, `COMPOSE_FILE=compose.yaml:src/experiments/evidence/compose.override.yaml`. Параметры стенда и запуск: [07-compose-secrets.md](07-compose-secrets.md).
|
||||
|
||||
### Команда
|
||||
|
||||
```sh
|
||||
docker compose --env-file .env exec -T db sh -c 'exec psql -X -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB"'
|
||||
```
|
||||
|
||||
### SQL, переданный на stdin
|
||||
|
||||
```sql
|
||||
SELECT version, dirty FROM schema_migrations;
|
||||
SELECT tablename FROM pg_tables WHERE schemaname='public' ORDER BY tablename;
|
||||
SELECT table_name, column_name, data_type FROM information_schema.columns
|
||||
WHERE table_schema='public' ORDER BY table_name, ordinal_position;
|
||||
SELECT conrelid::regclass AS table_name, conname, pg_get_constraintdef(oid)
|
||||
FROM pg_constraint WHERE connamespace='public'::regnamespace ORDER BY 1,2;
|
||||
SELECT tablename,indexname,indexdef FROM pg_indexes WHERE schemaname='public' ORDER BY 1,2;
|
||||
SELECT (SELECT count(*) FROM users) AS users, (SELECT count(*) FROM chats) AS chats,
|
||||
(SELECT count(*) FROM chat_members) AS members, (SELECT count(*) FROM messages) AS messages;
|
||||
```
|
||||
|
||||
### Фактический вывод
|
||||
|
||||
```text
|
||||
version | dirty
|
||||
---------+-------
|
||||
2 | f
|
||||
(1 row)
|
||||
|
||||
tablename
|
||||
-------------------
|
||||
chat_members
|
||||
chats
|
||||
messages
|
||||
schema_migrations
|
||||
users
|
||||
(5 rows)
|
||||
|
||||
table_name | column_name | data_type
|
||||
-------------------+---------------+--------------------------
|
||||
chat_members | chat_id | uuid
|
||||
chat_members | user_id | uuid
|
||||
chats | id | uuid
|
||||
chats | title | text
|
||||
chats | created_at | timestamp with time zone
|
||||
messages | id | uuid
|
||||
messages | chat_id | uuid
|
||||
messages | sender_id | uuid
|
||||
messages | text | text
|
||||
messages | created_at | timestamp with time zone
|
||||
schema_migrations | version | bigint
|
||||
schema_migrations | dirty | boolean
|
||||
users | id | uuid
|
||||
users | username | character varying
|
||||
users | display_name | text
|
||||
users | password_hash | bytea
|
||||
users | created_at | timestamp with time zone
|
||||
(17 rows)
|
||||
|
||||
table_name | conname | pg_get_constraintdef
|
||||
-------------------+---------------------------+-----------------------------------------------------------------------------------
|
||||
schema_migrations | schema_migrations_pkey | PRIMARY KEY (version)
|
||||
users | users_display_name_check | CHECK (((char_length(display_name) >= 1) AND (char_length(display_name) <= 100)))
|
||||
users | users_pkey | PRIMARY KEY (id)
|
||||
users | users_username_check | CHECK (((username)::text ~ '^[a-z0-9_]{3,32}$'::text))
|
||||
users | users_username_key | UNIQUE (username)
|
||||
chats | chats_pkey | PRIMARY KEY (id)
|
||||
chats | chats_title_check | CHECK (((char_length(title) >= 1) AND (char_length(title) <= 100)))
|
||||
chat_members | chat_members_chat_id_fkey | FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE
|
||||
chat_members | chat_members_pkey | PRIMARY KEY (chat_id, user_id)
|
||||
chat_members | chat_members_user_id_fkey | FOREIGN KEY (user_id) REFERENCES users(id)
|
||||
messages | messages_chat_id_fkey | FOREIGN KEY (chat_id) REFERENCES chats(id)
|
||||
messages | messages_pkey | PRIMARY KEY (id)
|
||||
messages | messages_sender_id_fkey | FOREIGN KEY (sender_id) REFERENCES users(id)
|
||||
messages | messages_text_check | CHECK (((char_length(text) >= 1) AND (char_length(text) <= 4000)))
|
||||
(14 rows)
|
||||
|
||||
tablename | indexname | indexdef
|
||||
-------------------+------------------------+----------------------------------------------------------------------------------------------
|
||||
chat_members | chat_members_pkey | CREATE UNIQUE INDEX chat_members_pkey ON public.chat_members USING btree (chat_id, user_id)
|
||||
chat_members | chat_members_user_idx | CREATE INDEX chat_members_user_idx ON public.chat_members USING btree (user_id, chat_id)
|
||||
chats | chats_pkey | CREATE UNIQUE INDEX chats_pkey ON public.chats USING btree (id)
|
||||
messages | messages_history_idx | CREATE INDEX messages_history_idx ON public.messages USING btree (chat_id, created_at, id)
|
||||
messages | messages_pkey | CREATE UNIQUE INDEX messages_pkey ON public.messages USING btree (id)
|
||||
schema_migrations | schema_migrations_pkey | CREATE UNIQUE INDEX schema_migrations_pkey ON public.schema_migrations USING btree (version)
|
||||
users | users_pkey | CREATE UNIQUE INDEX users_pkey ON public.users USING btree (id)
|
||||
users | users_username_key | CREATE UNIQUE INDEX users_username_key ON public.users USING btree (username)
|
||||
(8 rows)
|
||||
|
||||
users | chats | members | messages
|
||||
-------+-------+---------+----------
|
||||
0 | 0 | 0 | 0
|
||||
(1 row)
|
||||
```
|
||||
|
||||
Код завершения: `0`.
|
||||
Reference in New Issue
Block a user