@@ -39,6 +39,7 @@ ClearTranscriptBot
3939│ │ ├── history.py
4040│ │ ├── price.py
4141│ │ ├── rate_transcription.py
42+ │ │ ├── send_as_text.py
4243│ │ ├── summarize.py
4344│ │ ├── text.py
4445│ │ └── topup.py
@@ -51,6 +52,7 @@ ClearTranscriptBot
5152│ ├── history.py
5253│ ├── price.py
5354│ ├── rate.py
55+ │ ├── send_as_text.py
5456│ ├── summarize.py
5557│ ├── text.py
5658│ └── topup.py
@@ -187,7 +189,7 @@ CREATE TABLE IF NOT EXISTS users (
187189CREATE TABLE IF NOT EXISTS transcription_history (
188190 id BIGINT PRIMARY KEY AUTO_INCREMENT,
189191 user_id BIGINT NOT NULL ,
190- platform VARCHAR (16 ) NOT NULL ,
192+ user_platform VARCHAR (16 ) NOT NULL ,
191193 status VARCHAR (32 ) NOT NULL ,
192194 audio_s3_path TEXT NOT NULL ,
193195 result_json TEXT ,
@@ -204,11 +206,10 @@ CREATE TABLE IF NOT EXISTS transcription_history (
204206 created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
205207 started_at TIMESTAMP ,
206208 finished_at TIMESTAMP ,
207- FOREIGN KEY (user_id, user_platform) REFERENCES users(user_id, user_platform)
209+ FOREIGN KEY (user_id, user_platform) REFERENCES users(user_id, user_platform),
210+ INDEX idx_th_user (user_id, user_platform)
208211);
209212
210- CREATE INDEX idx_th_user ON transcription_history(user_id, user_platform);
211-
212213-- Payments processed via Tinkoff acquiring
213214CREATE TABLE IF NOT EXISTS payments (
214215 id INTEGER PRIMARY KEY AUTO_INCREMENT,
@@ -224,29 +225,28 @@ CREATE TABLE IF NOT EXISTS payments (
224225 tinkoff_response TEXT NOT NULL ,
225226 next_check_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
226227 created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
227- FOREIGN KEY (user_id, user_platform) REFERENCES users(user_id, user_platform)
228+ FOREIGN KEY (user_id, user_platform) REFERENCES users(user_id, user_platform),
229+ INDEX idx_payments_user (user_id, user_platform)
228230);
229231
230- CREATE INDEX idx_payments_user ON payments(user_id, user_platform);
231-
232232-- AI summarization requests for completed transcriptions
233233CREATE TABLE IF NOT EXISTS summarizations (
234234 id INTEGER PRIMARY KEY AUTO_INCREMENT,
235235 transcription_id INTEGER NOT NULL REFERENCES transcription_history(id),
236236 user_id BIGINT NOT NULL ,
237- platform VARCHAR (16 ) NOT NULL ,
237+ user_platform VARCHAR (16 ) NOT NULL ,
238238 status VARCHAR (32 ) NOT NULL ,
239239 operation_id VARCHAR (64 ),
240240 result_text TEXT ,
241241 llm_model VARCHAR (64 ),
242242 message_id VARCHAR (64 ),
243243 created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
244244 finished_at TIMESTAMP ,
245- FOREIGN KEY (user_id, user_platform) REFERENCES users(user_id, user_platform)
245+ FOREIGN KEY (user_id, user_platform) REFERENCES users(user_id, user_platform),
246+ INDEX idx_summarizations_transcription_id (transcription_id),
247+ INDEX idx_sum_user (user_id, user_platform)
246248);
247249
248- CREATE INDEX idx_summarizations_transcription_id ON summarizations(transcription_id);
249-
250250-- Trigger to maintain users.total_topped_up automatically.
251251-- Fires after each payment row update; adds amount only when status
252252-- transitions to CONFIRMED to avoid double-counting.
0 commit comments