feat: implement persistent messenger with PostgreSQL and Redis
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
@@ -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')
|
||||
Reference in New Issue
Block a user