feat: implement persistent messenger with PostgreSQL and Redis
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
sashadugina06
2026-10-30 14:02:09 +03:00
parent 65003b6119
commit bd34c1050a
40 changed files with 2879 additions and 24 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
"""Миграция с нуля и повторно, в изолированной схеме с ROLLBACK."""
from pathlib import Path
import subprocess
from uuid import uuid4
schema = 'audit_' + uuid4().hex
migration = Path('db/migrations/001_initial.sql').read_text()
sql = f'BEGIN; CREATE SCHEMA {schema}; SET LOCAL search_path TO {schema};\n'
sql += migration + '\n' + migration
sql += "\nSELECT count(*) = 5 AS five_tables FROM information_schema.tables WHERE table_schema = '" + schema + "';\nROLLBACK;\n"
result = subprocess.run(['docker', 'compose', 'exec', '-T', 'postgres', 'psql',
'-v', 'ON_ERROR_STOP=1', '-U', 'messenger', '-d', 'messenger', '-At'],
input=sql, text=True, capture_output=True, check=True)
assert 't' in result.stdout.splitlines(), result.stdout
print('PASS: migration creates five tables from zero and reapplies without errors; rolled back')