Coverage for toardb/timeseries/models_changelog.py: 100%
19 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-03 20:32 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-03 20:32 +0000
1# SPDX-FileCopyrightText: 2021 Forschungszentrum Jülich GmbH
2# SPDX-License-Identifier: MIT
4"""
5class TimeseriesChangelog(Base)
6===============================
7"""
8from sqlalchemy import Column, DateTime, ForeignKey, BigInteger, String, CHAR, text, \
9 Text, Table, Sequence
10from sqlalchemy.orm import relationship
11from .models_core import Timeseries
12from toardb.auth_user.models import AuthUser
13from toardb.base import Base
15class TimeseriesChangelog(Base):
16 """
17 Table "public.timeseries_changelog"
19 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
20 | Column | Type | Collation | Nullable | Default |
21 +================+==========================+===========+==========+==================================================+
22 | datetime | timestamp with time zone | | not null | now() |
23 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
24 | timeseries_id | bigint | | not null | |
25 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
26 | type_of_change | integer | | not null | |
27 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
28 | description | text | | not null | |
29 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
30 | old_value | character varying(256) | | not null | |
31 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
32 | new_value | character varying(256) | | not null | |
33 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
34 | period_start | timestamp with time zone | | | |
35 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
36 | period_end | timestamp with time zone | | | |
37 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
38 | version | character(28) | | | |
39 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
40 | author_id | integer | | not null | |
41 +----------------+--------------------------+-----------+----------+--------------------------------------------------+
43 Indexes:
44 "timeseries_changelog_pkey" PRIMARY KEY, btree (datetime)
45 Foreign-key constraints:
46 "timeseries_changelog_author_id_fk_auth_user_id" FOREIGN KEY (author_id) REFERENCES auth_user(id)
47 "timeseries_changelog_timeseries_id_fk_timeseries_id" FOREIGN KEY (timeseries_id) REFERENCES timeseries(id)
48 "timeseries_changelog_type_of_change_fk_cl_vocabulary_enum_val" FOREIGN KEY (type_of_change) REFERENCES cl_vocabulary(enum_val)
49 """
51 __tablename__ = 'timeseries_changelog'
53 datetime = Column(DateTime(True), primary_key=True, nullable=False, server_default=text("now()"))
54 description = Column(Text, nullable=False)
55 old_value = Column(String(256), nullable=False)
56 new_value = Column(String(256), nullable=False)
57 period_start = Column(DateTime(True))
58 period_end = Column(DateTime(True))
59 version = Column(CHAR(28))
60# do not use string declaration here (not working for pytest)
61# use the explicit class name here,
62# see: https://groups.google.com/forum/#!topic/sqlalchemy/YjGhE4d6K4U
63 timeseries_id = Column(ForeignKey(Timeseries.id), nullable=False)
64 author_id = Column(ForeignKey(AuthUser.id), nullable=False)
65# still to check for some pytest solution for controlled vocabulary
66 type_of_change = Column(ForeignKey('cl_vocabulary.enum_val'), nullable=False)
68 author = relationship('AuthUser')
69 timeseries = relationship('Timeseries')
71# cl_vocabulary = relationship('ClVocabulary')