Coverage for cc_modules/cc_dirtytables.py: 100%
11 statements
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2022-11-08 23:14 +0000
1#!/usr/bin/env python
3"""
4camcops_server/cc_modules/cc_dirtytables.py
6===============================================================================
8 Copyright (C) 2012, University of Cambridge, Department of Psychiatry.
9 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
11 This file is part of CamCOPS.
13 CamCOPS is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 CamCOPS is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
26===============================================================================
28**Representation of a "dirty table" -- one that a device is in the process of
29uploading to/preserving.**
31"""
33from sqlalchemy.schema import Column, ForeignKey
34from sqlalchemy.sql.sqltypes import Integer
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 = Column(
54 # new in 2.1.0; ditch composite PK
55 "id",
56 Integer,
57 primary_key=True,
58 autoincrement=True,
59 )
60 device_id = Column(
61 "device_id",
62 Integer,
63 ForeignKey(Device.id),
64 comment="Source tablet device ID",
65 )
66 tablename = Column(
67 "tablename",
68 TableNameColType,
69 comment="Table in the process of being preserved",
70 )