Coverage for cc_modules/cc_dirtytables.py: 100%
11 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-15 14:23 +0100
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-15 14:23 +0100
1"""
2camcops_server/cc_modules/cc_dirtytables.py
4===============================================================================
6 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
9 This file is part of CamCOPS.
11 CamCOPS is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 CamCOPS is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
24===============================================================================
26**Representation of a "dirty table" -- one that a device is in the process of
27uploading to/preserving.**
29"""
31from typing import Optional
33from sqlalchemy.orm import Mapped, mapped_column
34from sqlalchemy.schema import ForeignKey
36from camcops_server.cc_modules.cc_device import Device
37from camcops_server.cc_modules.cc_sqla_coltypes import TableNameColType
38from camcops_server.cc_modules.cc_sqlalchemy import Base
41# =============================================================================
42# DirtyTable
43# =============================================================================
46class DirtyTable(Base):
47 """
48 Class to represent tables being modified during a client upload.
49 """
51 __tablename__ = "_dirty_tables"
53 id: Mapped[int] = mapped_column(
54 # new in 2.1.0; ditch composite PK
55 primary_key=True,
56 autoincrement=True,
57 )
58 device_id: Mapped[Optional[int]] = mapped_column(
59 ForeignKey(Device.id),
60 comment="Source tablet device ID",
61 )
62 tablename: Mapped[Optional[str]] = mapped_column(
63 TableNameColType,
64 comment="Table in the process of being preserved",
65 )