feat: Добавлена каскадное удаление для моделей.
This commit is contained in:
parent
79e352037b
commit
12eea23299
@ -3,6 +3,7 @@ FROM python:3.10-slim
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libpq-dev \
|
||||
libmagic1 \
|
||||
postgresql-client \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
@ -15,4 +16,4 @@ COPY . .
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host=0.0.0.0"]
|
||||
CMD ["uvicorn", "app.main:app", "--host=0.0.0.0"]
|
||||
@ -11,5 +11,5 @@ class AppointmentType(BaseModel):
|
||||
|
||||
title = Column(VARCHAR(150), nullable=False, unique=True)
|
||||
|
||||
appointments = relationship('Appointment', back_populates='type')
|
||||
scheduled_appointments = relationship('ScheduledAppointment', back_populates='type')
|
||||
appointments = relationship('Appointment', back_populates='type', cascade="all, delete")
|
||||
scheduled_appointments = relationship('ScheduledAppointment', back_populates='type', cascade="all, delete")
|
||||
|
||||
@ -22,4 +22,4 @@ class Appointment(BaseModel):
|
||||
doctor = relationship('User', back_populates='appointments')
|
||||
type = relationship('AppointmentType', back_populates='appointments')
|
||||
|
||||
files = relationship('AppointmentFile', back_populates='appointment')
|
||||
files = relationship('AppointmentFile', back_populates='appointment', cascade="all, delete")
|
||||
|
||||
@ -30,4 +30,4 @@ class Lens(BaseModel):
|
||||
|
||||
type = relationship('LensType', back_populates='lenses')
|
||||
|
||||
lens_issues = relationship('LensIssue', back_populates='lens')
|
||||
lens_issues = relationship('LensIssue', back_populates='lens', cascade="all, delete")
|
||||
|
||||
@ -11,5 +11,5 @@ class LensType(BaseModel):
|
||||
|
||||
title = Column(VARCHAR(150), nullable=False, unique=True)
|
||||
|
||||
lenses = relationship('Lens', back_populates='type')
|
||||
contents = relationship('SetContent', back_populates='type')
|
||||
lenses = relationship('Lens', back_populates='type', cascade="all, delete")
|
||||
contents = relationship('SetContent', back_populates='type', cascade="all, delete")
|
||||
|
||||
@ -18,5 +18,5 @@ class Mailing(BaseModel):
|
||||
|
||||
user = relationship('User', back_populates='mailing')
|
||||
|
||||
recipients = relationship('Recipient', back_populates='mailing')
|
||||
mailing_options = relationship('MailingOption', back_populates='mailing')
|
||||
recipients = relationship('Recipient', back_populates='mailing', cascade="all, delete")
|
||||
mailing_options = relationship('MailingOption', back_populates='mailing', cascade="all, delete")
|
||||
|
||||
@ -11,4 +11,4 @@ class MailingDeliveryMethod(BaseModel):
|
||||
|
||||
title = Column(VARCHAR(200), nullable=False)
|
||||
|
||||
mailing = relationship('MailingOption', back_populates='method')
|
||||
mailing = relationship('MailingOption', back_populates='method', cascade="all, delete")
|
||||
|
||||
@ -13,5 +13,5 @@ class MailingOption(BaseModel):
|
||||
nullable=False)
|
||||
mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False)
|
||||
|
||||
method = relationship('MailingDeliveryMethod', back_populates='mailing')
|
||||
mailing = relationship('Mailing', back_populates='mailing_options')
|
||||
method = relationship('MailingDeliveryMethod', back_populates='mailing', cascade="all, delete")
|
||||
mailing = relationship('Mailing', back_populates='mailing_options', cascade="all, delete")
|
||||
|
||||
@ -19,7 +19,7 @@ class Patient(BaseModel):
|
||||
diagnosis = Column(String)
|
||||
correction = Column(String)
|
||||
|
||||
lens_issues = relationship('LensIssue', back_populates='patient')
|
||||
appointments = relationship('Appointment', back_populates='patient')
|
||||
mailing = relationship('Recipient', back_populates='patient')
|
||||
scheduled_appointments = relationship('ScheduledAppointment', back_populates='patient')
|
||||
lens_issues = relationship('LensIssue', back_populates='patient', cascade="all, delete")
|
||||
appointments = relationship('Appointment', back_populates='patient', cascade="all, delete")
|
||||
mailing = relationship('Recipient', back_populates='patient', cascade="all, delete")
|
||||
scheduled_appointments = relationship('ScheduledAppointment', back_populates='patient', cascade="all, delete")
|
||||
|
||||
@ -12,5 +12,5 @@ class Recipient(BaseModel):
|
||||
patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False)
|
||||
mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False)
|
||||
|
||||
patient = relationship('Patient', back_populates='mailing')
|
||||
mailing = relationship('Mailing', back_populates='recipients')
|
||||
patient = relationship('Patient', back_populates='mailing', cascade="all, delete")
|
||||
mailing = relationship('Mailing', back_populates='recipients', cascade="all, delete")
|
||||
|
||||
@ -11,4 +11,4 @@ class Set(BaseModel):
|
||||
|
||||
title = Column(VARCHAR(150), nullable=False, unique=True)
|
||||
|
||||
contents = relationship('SetContent', back_populates='set')
|
||||
contents = relationship('SetContent', back_populates='set', cascade="all, delete")
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
import datetime
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
from typing import Optional
|
||||
from fastapi_maintenance import maintenance_mode_on
|
||||
|
||||
import aiofiles
|
||||
import magic
|
||||
from fastapi import HTTPException, UploadFile
|
||||
from magic import magic
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, AsyncEngine
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from starlette.responses import FileResponse
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
@ -19,6 +19,13 @@ spec:
|
||||
ports:
|
||||
- containerPort: {{ .Values.service.port }}
|
||||
env:
|
||||
- name: PG_DUMP_PATH
|
||||
value: "{{ .Values.env.PG_DUMP_PATH }}"
|
||||
- name: BACKUP_DB_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: visus-api-secret
|
||||
key: BACKUP_DB_URL
|
||||
- name: SECRET_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
||||
@ -32,4 +32,5 @@ ingress:
|
||||
env:
|
||||
LOG_LEVEL: info
|
||||
LOG_FILE: logs/app.log
|
||||
ALGORITHM: HS256
|
||||
ALGORITHM: HS256
|
||||
PG_DUMP_PATH: pg_dump
|
||||
@ -12,4 +12,6 @@ pyjwt==2.10.1
|
||||
python-magic==0.4.27
|
||||
aiofiles==24.1.0
|
||||
python-multipart==0.0.20
|
||||
fastapi-maintenance==0.0.4
|
||||
fastapi-maintenance==0.0.4
|
||||
python-magic==0.4.27
|
||||
libmagic==1.0
|
||||
Loading…
x
Reference in New Issue
Block a user