From 6d7ba4fa56b9f54379d60d8b8281e921669eaaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sabine=20Schr=C3=B6der?= <s.schroeder@fz-juelich.de> Date: Tue, 6 Oct 2020 22:31:59 +0200 Subject: [PATCH] #17: removed column id from changelog tables --- toardb/stationmeta/models_changelog.py | 8 ++------ toardb/stationmeta/schemas.py | 2 -- toardb/timeseries/models_changelog.py | 8 ++------ toardb/timeseries/schemas.py | 2 -- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/toardb/stationmeta/models_changelog.py b/toardb/stationmeta/models_changelog.py index 3848c97..f380265 100644 --- a/toardb/stationmeta/models_changelog.py +++ b/toardb/stationmeta/models_changelog.py @@ -10,15 +10,12 @@ from .models_core import StationmetaCore from toardb.auth_user.models import AuthUser from toardb.base import Base -STATIONMETA_CHANGELOG_ID_SEQ = Sequence('stationmeta_changelog_id_seq') # define sequence explicitly class StationmetaChangelog(Base): """ Table "public.stationmeta_changelog" +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ | Column | Type | Collation | Nullable | Default | +================+==========================+===========+==========+========================================================+ - | id | bigint | | not null | nextval('stationmeta_changelog_id_seq'::regclass) | - +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ | datetime | timestamp with time zone | | not null | now() | +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ | station_id | bigint | | not null | | @@ -34,7 +31,7 @@ class StationmetaChangelog(Base): | author_id | integer | | not null | | +----------------+--------------------------+-----------+----------+--------------------------------------------------------+ Indexes: - "stationmeta_changelog_pkey" PRIMARY KEY, btree (id) + "timeseries_changelog_pkey" PRIMARY KEY, btree (datetime) Foreign-key constraints: "stationmeta_changelog_author_id_fk_auth_user_id" FOREIGN KEY (author_id) REFERENCES auth_user(id) "stationmeta_changelog_station_id_fk_stationmeta_core_id" FOREIGN KEY (station_id) REFERENCES stationmeta_core(id) @@ -42,8 +39,7 @@ class StationmetaChangelog(Base): """ __tablename__ = 'stationmeta_changelog' - id = Column(BigInteger, STATIONMETA_CHANGELOG_ID_SEQ, primary_key=True, server_default=STATIONMETA_CHANGELOG_ID_SEQ.next_value()) - datetime = Column(DateTime(True), nullable=False, server_default=text("now()")) + datetime = Column(DateTime(True), primary_key=True, nullable=False, server_default=text("now()")) description = Column(Text, nullable=False) old_value = Column(String(256), nullable=False) new_value = Column(String(256), nullable=False) diff --git a/toardb/stationmeta/schemas.py b/toardb/stationmeta/schemas.py index 520d3fc..cfb8046 100644 --- a/toardb/stationmeta/schemas.py +++ b/toardb/stationmeta/schemas.py @@ -452,7 +452,6 @@ class StationmetaRole(StationmetaRoleBase): # ======== StationmetaChangelog ========= class StationmetaChangelogBase(BaseModel): - id: int datetime: dt.datetime description: str old_value: str @@ -463,7 +462,6 @@ class StationmetaChangelogBase(BaseModel): class StationmetaChangelog(StationmetaChangelogBase): - id: int class Config: orm_mode = True diff --git a/toardb/timeseries/models_changelog.py b/toardb/timeseries/models_changelog.py index 235c464..6e97f38 100644 --- a/toardb/timeseries/models_changelog.py +++ b/toardb/timeseries/models_changelog.py @@ -10,15 +10,12 @@ from .models_core import Timeseries from toardb.auth_user.models import AuthUser from toardb.base import Base -TIMESERIES_CHANGELOG_ID_SEQ = Sequence('timeseries_changelog_id_seq') # define sequence explicitly class TimeseriesChangelog(Base): """ Table "public.timeseries_changelog" +----------------+--------------------------+-----------+----------+--------------------------------------------------+ | Column | Type | Collation | Nullable | Default | +================+==========================+===========+==========+==================================================+ - | id | bigint | | not null | nextval('timeseries_changelog_id_seq'::regclass) | - +----------------+--------------------------+-----------+----------+--------------------------------------------------+ | datetime | timestamp with time zone | | not null | now() | +----------------+--------------------------+-----------+----------+--------------------------------------------------+ | timeseries_id | bigint | | not null | | @@ -40,7 +37,7 @@ class TimeseriesChangelog(Base): | author_id | integer | | not null | | +----------------+--------------------------+-----------+----------+--------------------------------------------------+ Indexes: - "timeseries_changelog_pkey" PRIMARY KEY, btree (id) + "timeseries_changelog_pkey" PRIMARY KEY, btree (datetime) Foreign-key constraints: "timeseries_changelog_author_id_fk_auth_user_id" FOREIGN KEY (author_id) REFERENCES auth_user(id) "timeseries_changelog_timeseries_id_fk_timeseries_id" FOREIGN KEY (timeseries_id) REFERENCES timeseries(id) @@ -49,8 +46,7 @@ class TimeseriesChangelog(Base): __tablename__ = 'timeseries_changelog' - id = Column(BigInteger, TIMESERIES_CHANGELOG_ID_SEQ, primary_key=True, server_default=TIMESERIES_CHANGELOG_ID_SEQ.next_value()) - datetime = Column(DateTime(True), nullable=False, server_default=text("now()")) + datetime = Column(DateTime(True), primary_key=True, nullable=False, server_default=text("now()")) description = Column(Text, nullable=False) old_value = Column(String(256), nullable=False) new_value = Column(String(256), nullable=False) diff --git a/toardb/timeseries/schemas.py b/toardb/timeseries/schemas.py index 8abc5f1..6be64c7 100644 --- a/toardb/timeseries/schemas.py +++ b/toardb/timeseries/schemas.py @@ -201,7 +201,6 @@ class TimeseriesProgramme(TimeseriesProgrammeBase): # ======== TimeseriesChangelog ========= class TimeseriesChangelogBase(BaseModel): - id: int datetime: dt.datetime description: str old_value: str @@ -215,7 +214,6 @@ class TimeseriesChangelogBase(BaseModel): class TimeseriesChangelog(TimeseriesChangelogBase): - id: int class Config: orm_mode = True -- GitLab