Files
filwordspl-backend/database_schema.md
T

18 KiB

🗄 Схема базы данных

achievements

Колонка Тип NULL Default
id integer NO nextval('achievements_id_seq'::regclass)
code text NO
category text YES 'general'::text
name_pl text NO
name_ru text NO
name_uk text NO
name_en text NO
description_pl text YES ''::text
description_ru text YES ''::text
description_uk text YES ''::text
description_en text YES ''::text
icon text YES '🏆'::text
requirement_type text NO
requirement_value integer YES 0

ai_user_context

Колонка Тип NULL Default
user_id bigint NO
current_level character varying YES
completed_topics integer YES 0
completed_lessons integer YES 0
overall_mastery numeric YES
strong_skills jsonb YES '[]'::jsonb
weak_skills jsonb YES '[]'::jsonb
uncertain_skills jsonb YES '[]'::jsonb
recurring_errors jsonb YES '[]'::jsonb
recommended_topics jsonb YES '[]'::jsonb
recommended_lessons jsonb YES '[]'::jsonb
last_analysis_at timestamp without time zone YES
analytics_enabled boolean YES false
level_topics_total integer YES 0
level_completion_percent numeric YES 0

bubble_words_progress

Колонка Тип NULL Default
user_id bigint NO
levels_completed integer YES 0
total_score integer YES 0
recent_words ARRAY YES '{}'::text[]
level text YES 'A1'::text
current_hints_used integer YES 0

chat_history

Колонка Тип NULL Default
id integer NO nextval('chat_history_id_seq'::regclass)
user_id bigint YES
message text NO
is_user boolean YES true
created_at timestamp without time zone YES now()

chat_usage

Колонка Тип NULL Default
id integer NO nextval('chat_usage_id_seq'::regclass)
user_id bigint YES
usage_date date YES CURRENT_DATE
message_count integer YES 0

daily_logins

Колонка Тип NULL Default
user_id bigint NO
login_date date NO CURRENT_DATE

daily_phrases

Колонка Тип NULL Default
id integer NO nextval('daily_phrases_id_seq'::regclass)
phrase_date date NO
phrase_pl text NO
translations jsonb NO '{}'::jsonb
grammar_breakdowns jsonb NO '{}'::jsonb
created_at timestamp without time zone YES now()

feed_attachments

Колонка Тип NULL Default
id bigint NO nextval('feed_attachments_id_seq'::regclass)
post_id bigint NO
file_path text NO
file_type text YES 'image'::text
order_number integer NO 0
created_at timestamp without time zone YES now()

feed_posts

Колонка Тип NULL Default
id bigint NO nextval('feed_posts_id_seq'::regclass)
section text NO
source_language text NO 'ru'::text
title_pl text YES
title_ru text YES
title_uk text YES
title_en text YES
body_pl text YES
body_ru text YES
body_uk text YES
body_en text YES
link_url text YES
telegram_url text YES
author_id bigint NO
is_pinned boolean YES false
is_published boolean YES true
created_at timestamp without time zone YES now()
updated_at timestamp without time zone YES now()
edited_at timestamp without time zone YES
expires_at timestamp without time zone YES

learning_lessons

Колонка Тип NULL Default
id integer NO nextval('learning_lessons_id_seq'::regclass)
lesson_id character varying NO
topic_id character varying NO
order_number integer NO
skill_tag character varying NO
title_pl text NO
title_ru text NO
title_uk text NO
title_en text NO
objective_pl text YES
objective_ru text YES
objective_uk text YES
objective_en text YES
explanation_pl text YES
explanation_ru text YES
explanation_uk text YES
explanation_en text YES
is_active boolean YES true
edited_at timestamp without time zone YES

learning_levels

Колонка Тип NULL Default
id integer NO nextval('learning_levels_id_seq'::regclass)
code character varying NO
name_pl text NO
name_ru text NO
name_uk text NO
name_en text NO
sort_order integer NO
is_active boolean YES true

learning_questions

Колонка Тип NULL Default
id integer NO nextval('learning_questions_id_seq'::regclass)
question_id character varying NO
lesson_id character varying YES
topic_id character varying NO
context_type character varying NO
question_type character varying NO
skill_tag character varying NO
difficulty integer NO
prompt_pl text YES
prompt_ru text YES
prompt_uk text YES
prompt_en text YES
correct_answer text YES
hint_type character varying YES
hint_value text YES
is_test_question boolean YES false
test_order integer YES
options_language text YES 'pl'::text
edited_at timestamp without time zone YES

learning_sessions

Колонка Тип NULL Default
id bigint NO nextval('learning_sessions_id_seq'::regclass)
user_id bigint NO
level_code character varying NO
topic_id character varying NO
session_type character varying NO
started_at timestamp without time zone NO now()
completed_at timestamp without time zone YES
is_completed boolean YES false

learning_topics

Колонка Тип NULL Default
id integer NO nextval('learning_topics_id_seq'::regclass)
topic_id character varying NO
level_code character varying NO
order_number integer NO
name_pl text NO
name_ru text NO
name_uk text NO
name_en text NO
description_pl text YES
description_ru text YES
description_uk text YES
description_en text YES
is_active boolean YES true
edited_at timestamp without time zone YES

lesson_examples

Колонка Тип NULL Default
id integer NO nextval('lesson_examples_id_seq'::regclass)
lesson_id character varying NO
order_number integer NO
text_pl text NO
text_ru text YES
text_uk text YES
text_en text YES
audio_url text YES
edited_at timestamp without time zone YES

lesson_progress

Колонка Тип NULL Default
id integer NO nextval('lesson_progress_id_seq'::regclass)
user_id bigint YES
level text YES 'A1'::text
topic text YES ''::text
correct_count integer YES 0
total_questions integer YES 0
created_at timestamp without time zone YES now()

level_words

Колонка Тип NULL Default
id integer NO nextval('level_words_id_seq'::regclass)
level_id integer YES
word_pl text NO
translation_ru text YES ''::text
translation_uk text YES ''::text
translation_en text YES ''::text
level text YES 'A1'::text
edited_at timestamp without time zone YES

levels

Колонка Тип NULL Default
id integer NO nextval('levels_id_seq'::regclass)
level_number integer NO
grid_size integer NO
game_type text YES 'wordsearch'::text
theme text YES ''::text
grid_letters jsonb NO '[]'::jsonb
word_paths jsonb NO '{}'::jsonb
level text YES 'A1'::text

question_options

Колонка Тип NULL Default
id integer NO nextval('question_options_id_seq'::regclass)
question_id character varying NO
option_key character varying NO
text_pl text YES
text_ru text YES
text_uk text YES
text_en text YES
is_correct boolean NO
wrong_because character varying YES
edited_at timestamp without time zone YES

sentence_hints_used ⚠️ устаревшая (не используется)

Колонка Тип NULL Default
user_id bigint NO
sentence_id integer NO
used_at timestamp without time zone YES now()

sentence_progress

Колонка Тип NULL Default
user_id bigint NO
sentence_id integer NO
completed_at timestamp without time zone YES
score integer YES 0
level text YES 'A1'::text

sentences

Колонка Тип NULL Default
id integer NO nextval('sentences_id_seq'::regclass)
sentence_number integer NO
theme text YES ''::text
sentence_pl text NO
translation_ru text YES ''::text
translation_uk text YES ''::text
translation_en text YES ''::text
difficulty integer YES 1
level text YES 'A1'::text
edited_at timestamp without time zone YES

support_messages

Колонка Тип NULL Default
id bigint NO nextval('support_messages_id_seq'::regclass)
ticket_id bigint NO
sender_id bigint NO
message text NO
is_read boolean YES false
created_at timestamp without time zone YES now()

support_tickets

Колонка Тип NULL Default
id bigint NO nextval('support_tickets_id_seq'::regclass)
user_id bigint NO
status text YES 'open'::text
created_at timestamp without time zone YES now()
updated_at timestamp without time zone YES now()

teacher_ai_usage

Колонка Тип NULL Default
id bigint NO nextval('teacher_ai_usage_id_seq'::regclass)
user_id bigint NO
usage_date date YES CURRENT_DATE
command_count integer YES 0

teacher_chat_history

Колонка Тип NULL Default
id bigint NO nextval('teacher_chat_history_id_seq'::regclass)
user_id bigint NO
messages jsonb NO '[]'::jsonb
updated_at timestamp without time zone YES now()

teacher_reactions

Колонка Тип NULL Default
id integer NO nextval('teacher_reactions_id_seq'::regclass)
reaction_type character varying NO
text_pl text NO
text_ru text NO
text_uk text NO
text_en text NO

typing_hints_used

Колонка Тип NULL Default
user_id bigint NO
sentence_id integer NO
used_at timestamp without time zone YES now()

typing_progress

Колонка Тип NULL Default
user_id bigint NO
sentence_id integer NO
completed_at timestamp without time zone YES now()

user_achievements

Колонка Тип NULL Default
user_id bigint NO
achievement_id integer NO
unlocked_at timestamp without time zone YES now()

user_learning_answers

Колонка Тип NULL Default
id bigint NO nextval('user_learning_answers_id_seq'::regclass)
user_id bigint NO
session_id bigint NO
level_code character varying NO
topic_id character varying NO
lesson_id character varying YES
question_id character varying NO
selected_answer text YES
correct boolean YES
skill_tag character varying NO
question_type character varying NO
context_type character varying NO
difficulty integer NO
time_taken_ms integer YES
attempt_number integer YES 1
hint_used boolean YES false
wrong_because character varying YES
is_final_answer boolean YES true
created_at timestamp without time zone YES now()

user_learning_answers_archive

Колонка Тип NULL Default
id bigint NO nextval('user_learning_answers_archive_id_seq'::re
user_id bigint NO
skill_tag character varying NO
correct boolean YES
wrong_because character varying YES
created_at date YES
archived_at timestamp without time zone YES now()

user_lesson_progress

Колонка Тип NULL Default
id bigint NO nextval('user_lesson_progress_id_seq'::regclass)
user_id bigint NO
lesson_id character varying NO
started_at timestamp without time zone YES
completed_at timestamp without time zone YES
attempts_count integer YES 0
correct_count integer YES 0
best_score numeric YES
average_time_ms integer YES
completed boolean YES false

user_progress

Колонка Тип NULL Default
user_id bigint NO
level_id integer NO
completed_at timestamp without time zone YES
hints_used integer YES 0
score integer YES 0
level text YES 'A1'::text
current_streak integer YES 0

user_skill_mastery

Колонка Тип NULL Default
id bigint NO nextval('user_skill_mastery_id_seq'::regclass)
user_id bigint NO
skill_tag character varying NO
attempts_count integer YES 0
correct_count integer YES 0
recognition_score numeric YES
production_score numeric YES
application_score numeric YES
retention_score numeric YES
hint_dependency numeric YES
average_time_ms integer YES
recent_accuracy numeric YES
long_term_accuracy numeric YES
mastery_score numeric YES
confidence numeric YES
last_attempt_at timestamp without time zone YES
median_time_ms integer YES 0
recognition_attempts integer YES 0
recognition_correct integer YES 0
production_attempts integer YES 0
production_correct integer YES 0
application_attempts integer YES 0
application_correct integer YES 0
median_correct_time_ms integer YES 0
median_wrong_time_ms integer YES 0
last_3_accuracy numeric YES
last_5_accuracy numeric YES
last_10_accuracy numeric YES
error_count integer YES 0
repeated_error_count integer YES 0
days_since_last_attempt integer YES 0
previous_mastery_score numeric YES 0
mastery_delta numeric YES 0
trend text YES 'insufficient_data'::text
retention_status text YES 'fresh'::text
fluency_score numeric YES 0
passive_knowledge_score numeric YES 0
active_knowledge_score numeric YES 0

user_topic_progress

Колонка Тип NULL Default
id bigint NO nextval('user_topic_progress_id_seq'::regclass)
user_id bigint NO
topic_id character varying NO
lessons_total integer YES 0
lessons_completed integer YES 0
test_started boolean YES false
test_completed boolean YES false
test_score numeric YES
topic_mastery numeric YES
confidence numeric YES
completed_at timestamp without time zone YES

users

Колонка Тип NULL Default
telegram_id bigint NO
username text YES
app_language text YES 'pl'::text
created_at timestamp without time zone YES now()
last_completed_level integer YES 0
id integer NO nextval('users_id_seq'::regclass)
current_level text YES 'A1'::text
difficulty text YES 'medium'::text

voice_usage

Колонка Тип NULL Default
id integer NO nextval('voice_usage_id_seq'::regclass)
user_id bigint YES
usage_date date YES CURRENT_DATE
voice_count integer YES 0

word_quiz_progress

Колонка Тип NULL Default
user_id bigint NO
words_guessed integer YES 0
total_score integer YES 0
correct_streak integer YES 0
recent_words ARRAY YES '{}'::text[]
level text YES 'A1'::text
current_mistakes integer YES 0

wrong_because_explanations

Колонка Тип NULL Default
id integer NO nextval('wrong_because_explanations_id_seq'::regcl
wrong_because character varying NO
explanation_pl text NO
explanation_ru text NO
explanation_uk text NO
explanation_en text NO